ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hyperlink to Word Template (https://www.excelbanter.com/excel-programming/363830-hyperlink-word-template.html)

Steve C

Hyperlink to Word Template
 
In Excel, I want to create a link to a Word template. However, I want Word
to open in a new document and not open the template itself. Do I need
programming to do this (and assign it to a command button instead)? Thanks!
--
Steve C

Heather Heritage

Hyperlink to Word Template
 
A hyperlink will open a the link - so yes, if you want to do FILE NEW (i.e a
new document based on the template) then you will need a macro - so a button
would be the obvious way forward!
"Steve C" wrote in message
...
In Excel, I want to create a link to a Word template. However, I want

Word
to open in a new document and not open the template itself. Do I need
programming to do this (and assign it to a command button instead)?

Thanks!
--
Steve C




Steve C

Hyperlink to Word Template
 
What is the programming code I would need to make it open as a new document
instead of a template? Thanks!
--
Steve C


"Steve C" wrote:

In Excel, I want to create a link to a Word template. However, I want Word
to open in a new document and not open the template itself. Do I need
programming to do this (and assign it to a command button instead)? Thanks!
--
Steve C


Dave Peterson

Hyperlink to Word Template
 
Can you add a shape/button and assign a macro to that shape?

Option Explicit
Sub testme01()

Dim oWord As Object
Dim myWordTemplate As String
Dim testStr As String

myWordTemplate = "c:\msoffice\templates\1033\Elegant Fax.dot"

testStr = ""
On Error Resume Next
testStr = Dir(myWordTemplate)
On Error GoTo 0
If testStr = "" Then
MsgBox myWordTemplate & " doesn't exist"
Exit Sub
End If

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err Then
Set oWord = CreateObject("Word.Application")
End If

oWord.Visible = True
oWord.Documents.Add Template:=myWordTemplate

End Sub

Steve C wrote:

In Excel, I want to create a link to a Word template. However, I want Word
to open in a new document and not open the template itself. Do I need
programming to do this (and assign it to a command button instead)? Thanks!
--
Steve C


--

Dave Peterson

Steve C

Hyperlink to Word Template
 
I created a command button and assigned your code to it. Works perfectly.
Thanks, Dave!
--
Steve C


"Dave Peterson" wrote:

Can you add a shape/button and assign a macro to that shape?

Option Explicit
Sub testme01()

Dim oWord As Object
Dim myWordTemplate As String
Dim testStr As String

myWordTemplate = "c:\msoffice\templates\1033\Elegant Fax.dot"

testStr = ""
On Error Resume Next
testStr = Dir(myWordTemplate)
On Error GoTo 0
If testStr = "" Then
MsgBox myWordTemplate & " doesn't exist"
Exit Sub
End If

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err Then
Set oWord = CreateObject("Word.Application")
End If

oWord.Visible = True
oWord.Documents.Add Template:=myWordTemplate

End Sub

Steve C wrote:

In Excel, I want to create a link to a Word template. However, I want Word
to open in a new document and not open the template itself. Do I need
programming to do this (and assign it to a command button instead)? Thanks!
--
Steve C


--

Dave Peterson



All times are GMT +1. The time now is 08:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com