I need to insert a hyperlink in a file that will kick off a macro. What I
did was create a template (startmacro.dot) with this code:
sub autoopen()
Documents.Add Template:="mytemplate.dot"
end sub
The hyperlink simply opens the startmacro.dot, which creates a new file
basing it on the mytemplate.dot template. The "mytemplate.dot" template
contains an autonew macro which executes my code. This all works fine.
What I have been unsuccessful with is closing the original template
(startmacro.dot). Perhaps there is another way of inserting a hyperlink to
accomplish this? Any help would be appreciated. Thanks.
Jean-Guy Marcil - 03 Oct 2006 21:57 GMT
klav was telling us:
klav nous racontait que :
> I need to insert a hyperlink in a file that will kick off a macro.
> What I did was create a template (startmacro.dot) with this code:
[quoted text clipped - 11 lines]
> (startmacro.dot). Perhaps there is another way of inserting a
> hyperlink to accomplish this? Any help would be appreciated. Thanks.
In your mytemplate.dot macro, add something like:
Dim docOpened as Documents
Dim i As Long
Set docOpened = Application.Documents
For i = 1 to docOpened.Count
If docOpened(i).Name = "startmacro.dot" Then
docOpened(i).Close wdDoNotSaveChanges
Exit Sub
End If
Next

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
klav - 04 Oct 2006 20:28 GMT
I had something like this in my file but I was getting Word
errors....however, I tried your code and it seems to be working OK. Thanks
very much.
> I need to insert a hyperlink in a file that will kick off a macro. What I
> did was create a template (startmacro.dot) with this code:
[quoted text clipped - 10 lines]
> (startmacro.dot). Perhaps there is another way of inserting a hyperlink to
> accomplish this? Any help would be appreciated. Thanks.