J
johnftough
Hi,
I am new to VBA.
I want to open a Word doc from within an Excel macro. This is no
problem. However, I want to open the Word doc using a template file. I
have tried various ways but without success. This is a bit of code I
used:
Dim AppWord As Object
Dim strTemplateName As String 'Path to Word Template file to use
strTemplateFile = "\\beastie\public\Word Templates\template.dot"
'
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
'
' the following line gives a compile error
'
AppWord.filenew Template:=strTemplateName
' hardcode a row for testing
Rows("4:4").Select
Selection.Copy
AppWord.Documents.Add
AppWord.Selection.Paste
Application.CutCopyMode = False
Set AppWord = Nothing
Does anyone have a solution?
Thanks.
I am new to VBA.
I want to open a Word doc from within an Excel macro. This is no
problem. However, I want to open the Word doc using a template file. I
have tried various ways but without success. This is a bit of code I
used:
Dim AppWord As Object
Dim strTemplateName As String 'Path to Word Template file to use
strTemplateFile = "\\beastie\public\Word Templates\template.dot"
'
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
'
' the following line gives a compile error
'
AppWord.filenew Template:=strTemplateName
' hardcode a row for testing
Rows("4:4").Select
Selection.Copy
AppWord.Documents.Add
AppWord.Selection.Paste
Application.CutCopyMode = False
Set AppWord = Nothing
Does anyone have a solution?
Thanks.