| 
				                                 Timo Goebel                				 
                					 
                     
                
                
                
                                 
                 
                
                
                                 
                                        Posts: 5 
                                                        Joined: 2011-05-03 
                                                
         | 
        
                
                
                Dear forum,
 
 I wrote a Word/Excel add-in which sets the ReadOnlyRecommended flag of a document/workbook in the BeforeSave event. Up to Office 2003 this worked well. Now I tested the add-in under Office 2010 and found that ReadOnlyRecommended is not set anymore. 
 
 The BeforeSave event fires, sets the ReadOnlyRecommended flag (checked during debugging) but as soon as the SaveUI is displayed, the "read only recommended" checkbox (Tools, General Settings) is not checked and the file is saved without the flag.
  
 
procedure TAddInModule.adxWordAppEvents1DocumentBeforeSave(ASender: TObject;
  const Doc: _Document; var SaveAsUI, Cancel: WordBool);
var sFileExt: string;
begin
  Doc.ReadOnlyRecommended:=True;
end;
 
 
 I checked the dll under Office 2003 where it works as expected (the read only recommended flag is set). 
 
 Setting HostApp.ActiveDocument.ReadOnlyRecommended to true e.g. by a simple RibbonButton click also works, but that is not the desired result. 
 
 Specs: VCL Standard build 758, Delphi 2007, Office Pro Plus 2010 (Version 14.0.5128.5000, 32-Bit), Windows 7 (32-Bit), German OS and Office
 
 Any ideas?
 
 Kind regards
 
 Timo                 |   
                 
         | 
  
  
        | 
				                                 Dmitry Kostochko                				 
                					 					 
                
                
                
                 Add-in Express team                 
                 
                
                
                                 
                                        Posts: 2887 
                                                        Joined: 2004-04-05 
                                                
         | 
        
                
                
                Hi Timo,
 
 I have just tested your code against Word 2010 and can confirm that the issue exists in that Word version. Right now I can suggest using two TadxRibbonCommand components (IdMso:=FileSave and IdMso:=FileSaveAs) and setting the ReadOnlyRecommended property in their OnAction event handlers:
 
procedure TAddInModule.adxRibbonCommand2Action(Sender: TObject;
  const Pressed: Boolean; var Cancel: Boolean);
begin
  if (Self.HostType = ohaWord) and (Self.HostMajorVersion = 14) then
    WordApp.ActiveDocument.ReadOnlyRecommended := True;
end;
 
 
 I have tested the code above, it works fine.                 |   
                 
         | 
  
  
        | 
				                                 Timo Goebel                				 
                					 
                     
                
                
                
                                 
                 
                
                
                                 
                                        Posts: 5 
                                                        Joined: 2011-05-03 
                                                
         | 
        
                
                
                Hi Dmitry,
 
 thank you, this worked!
 
 Kind regards
 
 Timo                 |   
                 
         |