Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I opened word and created a new test2.dot template file.
I put this code under the ThisDocument module: Option Explicit Private Sub Document_New() MsgBox "hi from new" End Sub Private Sub Document_Open() MsgBox "hi from open" End Sub I put a hyperlink in a cell in an excel worksheet that pointed to that test2.dot file. The Document_Open() event fired--but the actual template (test2.dot) opened--a new document based on that template did NOT get created. I think you may want to change your technique if you want a new document based on that template to be created (and the Document_New event to fire). I'd put a button on the worksheet that has a macro assigned to it. It could create a new document based on that template. Option Explicit Sub testme() Dim myCell As Range Dim WdApp As Object Dim testStr As String Set myCell = ActiveSheet.Range("d12") 'or whatever you want testStr = "" On Error Resume Next testStr = Dir(myCell.Value) On Error GoTo 0 If testStr = "" Then MsgBox "Template file not found!" Exit Sub End If On Error Resume Next Set WdApp = GetObject(, "Word.Application") If Err.Number < 0 Then Err.Clear Set WdApp = CreateObject("Word.Application") End If With WdApp .Visible = True .Documents.Add Template:=myCell.Value, _ NewTemplate:=False, DocumentType:=0 End With Set WdApp = Nothing End Sub scottEfraz wrote: I have a word .dot that has a simple macro when opened, but when I try to open the .dot from a hyperlink the macro doesn't autostart. Any ideas? -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Closing File Error | Excel Discussion (Misc queries) | |||
Macro that will add data from multiple workbooks to the 1st open r | Excel Discussion (Misc queries) | |||
Open a hyperlink in a new page | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) | |||
How can I set up a Macro to automatically run when I open a speci. | Excel Discussion (Misc queries) |