Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

hyperlink

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
klav - 03 Oct 2006 18:25 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.