Posts 1 - 10 of 12
First | Prev. | 1 2 | Next | Last
|
|
Destaque Empreendimentos em Inform?tica
Guest
|
Hi for all,
we created an add-in that performs upload from the active document (in MS Word) every time that the user save it. Normally it works fine, but there are two users reporting that suddenly their MSWord change the current document name to something like "Auto-recovery ...".
When it occurs, the MS Word freeze if the user try save as. Then the user can not recover his work.
We can not simulate the error (in our tests it does not occur (but an important costumer has lost some documents). I want ask if anyone know a precondition to MS Word change the active document to an auto saved copy (with ASD extension, and not more DOC or DOCX)?
For a better comprehension I attached an image below (see the highlighted area):
Thank you for any help.
Sergio R. S. |
|
Posted 26 Feb, 2015 15:09:02
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18787
Joined: 2006-05-11
|
|
Posted 27 Feb, 2015 01:52:19
|
|
Top
|
|
Destaque Empreendimentos em Inform?tica
Guest
|
Thank you Andrei.
I want add two informations in the discussion:
1 - I have tried simulate the problem configuring the auto save function interval to 1 minute, (in Word) but I still can not simulate the problem (I have tested for more than one hour).
2 - I am not really using a flag to distinguish between an auto save, or user save. But I'm testing is the file extension is equals "ASD", and, if yes, I'm bypassing the save event.
Must I use the said flag? If yes, how can I do it in Delphi?
I searched in Google, but it is not easy (I'm trying use the Word2000.TWordApplication.WordBasic.invoke method, but I'm not understanding all parameters).
Is there an easer way to know if it is the automatic save call?
I need your help...
Sergio R. S. |
|
Posted 27 Feb, 2015 15:07:15
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18787
Joined: 2006-05-11
|
Sergio,
I would use the way described on that page. oBasic.GetType().InvokeMember("IsAutosaveEvent", BindingFlags.GetProperty, null, oBasic, null) is a C#-specific way of accessing a property using late binding. Note that if you only use Word 2013, you can use this property - https://msdn.microsoft.com/en-us/library/office/jj230857%28v=office.15%29.aspx.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 02 Mar, 2015 06:26:58
|
|
Top
|
|
Destaque Empreendimentos em Inform?tica
Guest
|
Hello Andrei,
Could you please explain to me how to that in Delphi? I'm finding it very difficult to do it.
Thanks! |
|
Posted 18 Mar, 2015 10:06:00
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18787
Joined: 2006-05-11
|
Hello Sergio,
procedure TAddInModule.adxWordAppEvents1DocumentBeforeSave(
ASender: TObject; const Doc: _Document; var SaveAsUI, Cancel: WordBool);
var
WordBasic: OleVariant;
IsAutoSave: bool;
begin
If self.HostMajorVersion > 11 then begin
WordBasic := self.WordApp.WordBasic;
IsAutoSave := WordBasic.IsAutosaveEvent;
OutputDebugString(PAnsiChar('!!! adxWordAppEvents1DocumentBeforeSave. IsAutoSave=' + BoolToStr(IsAutoSave) ));
end;
end;
Use DebugView (http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx) to collect the debug output generated by OutputDebugString at run time.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 19 Mar, 2015 03:44:30
|
|
Top
|
|
Destaque Empreendimentos em Inform?tica
Guest
|
Hello Andrei, thanks for the answer!
In Office 2013 it worked fine, but in Office 2007 it said: "Method isAutoSave event not supported by automation object". Is it not supported in 2003?
Other question: Do you have this code in Excel? We need to integrate with it too. |
|
Posted 19 Mar, 2015 08:33:16
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18787
Joined: 2006-05-11
|
Sergio,
That method is supported starting from Word 2007; this is mentioned at http://davecra.com/2011/05/04/auto-recovery-save-autosave-fires-off-the-documentbeforesave-event-in-word/. If this method doesn't work in your Word 2007, make sure you install all updates on Office 2007. There's no such method in Excel. Here's a suggestion I found long ago somewhere on the web:
===
I suggest that you use a flag to determine if the save was invoked by the user; you need to set that flag in event handlers of all Ribbon and CommandBar controls that the user may invoke to save the document. That is, if the user clicks such a control (or presses a key combination), you set a flag in the event handler of that control. You check the flag in DocumentBeforeSave: if the flag is set, this is a result of the user activity, otherwise (if the flag is not set) DocumentBeforeSave is triggered by AutoSave.
===
Hope this helps.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 19 Mar, 2015 09:01:18
|
|
Top
|
|
Destaque Empreendimentos em Inform?tica
Guest
|
Thanks Andrei!
The problem is that we intercept the default save action of the Word. Is there a method to set this flag on the save action BEFORE the DocumentBeforeSave? If there is, I don't know which. Can you help me with that?
Again, thanks for your answers and help! =) |
|
Posted 19 Mar, 2015 09:10:31
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18787
Joined: 2006-05-11
|
Sergio,
You can use an ADXRibbonCommand to intercept the Save command and can set this flag in the event handler of the ADXRibbonCommand.OnAction. Then you check this flag in the event handler for the DocumentBeforeSave event. When the user clicks the Save button, the events will be called in this order: ADXRibbonCommand.OnAction, DocumentBeforeSave. If this is AutoSave, in DocumentBeforeSave you'll find that the flag isn't set.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 19 Mar, 2015 09:31:10
|
|
Top
|
|
Posts 1 - 10 of 12
First | Prev. | 1 2 | Next | Last
|