Background backup

Add-in Express™ Support Service
That's what is more important than anything else

Background backup
 
wengchi wang




Posts: 1
Joined: 2017-12-11
Backup function is as follows:



procedure TAddInModule.autosave;
var
    i : integer;
    filename : String;
    olddoc : WordDocument;
    PF: IPersistFile; 
   // vDoc: Word2010._Document; 
begin
    for i:=0 to self.WordApp.Documents.Count-1 do begin
   
          //self.WordApp.Documents.
         // self.WordApp
     // Word2010._Document
     //      self.WordApp.Documents
           
         olddoc := self.WordApp.Documents.Item(i+1);
         filename :=  olddoc.Name; 
             filename := 'AUTOSAVE_'+olddoc.Name;                
             olddoc.QueryInterface(IPersistFile,PF);
                 if Assigned(PF) then begin
                     try 
                        PF.Save( pwidechar('c:\backup\' + filename),false);                             
                         finally
                         PF := nil;
                     end;
                 end;
                           
    end;

end;


In the win7 environment works well, but in win10 implementation, save the file dialog box pops up, is there any solution?
thank
Posted 11 Dec, 2017 13:00:22 Top
Andrei Smolin


Add-in Express team


Posts: 14593
Joined: 2006-05-11
Hello Wengchi,

I assume the dialog is shown when you call PF.Save(); is this correct? Also, are you saying that you see this difference when testing the *same* Word build on Windows 7 and Windows 10?

I would check if calling PF.Save() results in setting olddoc.Saved = true. If so, I would try to set olddoc.Saved := true before saving. Depending on results of testing, I would restore or not restore olddoc.Saved after the save.

Another possibility to hide the dialog would be to intercept the WordApp.DocumentBeforeSave event; it provides the SaveAsUI parameter which you can try to set to false.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Dec, 2017 04:09:08 Top