wengchi wang
Guest
|
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 |
|
Andrei Smolin
Add-in Express team
Posts: 18825
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.
Andrei Smolin
Add-in Express Team Leader |
|