Posts 11 - 18 of 18
First | Prev. | 1 2 | Next | Last
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Posted 13 Mar, 2007 06:05:26
|
|
Top
|
|
Michael McMahon
Posts: 56
Joined: 2005-05-03
|
Hi Sergey,
Thanks for your response. I have updated my solution to use the version of the ADX components you suggested however the issue still occurs.
It clearly seems to be something related to the add-in-express component because without them installed I don't get prompted to save the .dot file but with them installed I do.
Regards,
Mike |
|
Posted 14 Mar, 2007 02:36:22
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Mike.
Are you sure that both the Normal.dot and the document template don't have the 'ReadOnly' attribute? I have just tested this situation with the standard Word templates and I can't reproduce the issue?
You can also send me the project. I will test it on my PC.
|
|
Posted 14 Mar, 2007 06:42:12
|
|
Top
|
|
Michael McMahon
Posts: 56
Joined: 2005-05-03
|
Hi Sergey,
No the templates weren't read only. But after spending a bit more time on this I think I've managed to resolve the problem.
I found an article on the web were someone was having a similar problem. Basically what I have done is to use the Word API to tell Word that the attached template is saved.
I.e. objDoc.AttachedTemplate.Saved = True
I think we have to do this explicitly because we're hooking into the DocumentBeforeClose event and intercepting the Word save.
In addition to this I now hook into the DocumentBeforeSave event like this (by the way I also do this in the DocumentBeforeClose event along with quite a bit of other functionality):
Private Sub ObjWordEvents_DocumentBeforeSave(ByVal sender As Object, ByVal e As AddinExpress.MSO.ADXHostBeforeSaveEventArgs) Handles ObjWordEvents.DocumentBeforeSave
On Error Resume Next
Dim Cancel As Boolean = False
Dim objDoc As Object = objApp.ActiveDocument
objDoc.AttachedTemplate.Saved = True
End Sub
That seems to prevent the problem.
|
|
Posted 15 Mar, 2007 18:04:59
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Mike.
From my side, I will try to reproduce the issue and probably I will manage to do something in the Add-in Express code.
|
|
Posted 16 Mar, 2007 09:44:01
|
|
Top
|
|
Michael McMahon
Posts: 56
Joined: 2005-05-03
|
Thanks Sergey,
Just following up here on the solution that I posted the other day. I have had to modify this code a little bit so that the user can still save changes that they make to .dot files.
The code now looks like this:
'*****************************************************************************************
'* Name: ObjWordEvents_DocumentBeforeSave
'* Purpose: tell word not to prompt the user to save the attached template when they save
'* a document
'* Inputs: see method signature
'*****************************************************************************************
Private Sub ObjWordEvents_DocumentBeforeSave(ByVal sender As Object, ByVal e As AddinExpress.MSO.ADXHostBeforeSaveEventArgs) Handles ObjWordEvents.DocumentBeforeSave
On Error Resume Next
Dim Cancel As Boolean = False
Dim objDoc As Object = objApp.ActiveDocument
'Check to make sure that the file is not a template
If GetDocType(objDoc.Name, True) <> "dot" Then
objDoc.AttachedTemplate.Saved = True
End If
End Sub |
|
Posted 18 Mar, 2007 20:17:23
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Posted 19 Mar, 2007 09:02:08
|
|
Top
|
|
Ben Van Mulders
Posts: 27
Joined: 2007-03-14
|
Hi Mike,
Thanks for the code.
But with me it still asks to save my template file :(
(using Office 2007)
edit:
My bad.
Hadn't added it to the DocumentBeforeClose event (should read the whole post before posting) :-)
Thnx again |
|
Posted 19 Mar, 2007 09:25:33
|
|
Top
|
|
Posts 11 - 18 of 18
First | Prev. | 1 2 | Next | Last
|