Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink to Word Template

Status
Not open for further replies.

GeekGirlau

Programmer
Joined
Jul 29, 2001
Messages
216
Location
AU
I'd like to create a number of hyperlinks in a Word document that link to various shared Word templates. However I don't want the hyperlink to open the template; I want it to create a new document based on the template.

Basically I want it to perform the same function as if you selected File, New and double-clicked on a shared template.

I know I can create this option via code, but it's Friday and my brain is full so I was looking for a quick work-around.

Dreamboat? Anybody? [ponytails]
 
If under Tools, Templates and Add-ins the templates are attahced you should be able to do this.

You may need to place the templates under your profile\.....\application data\microsoft\word\templates

HTH

Indu
 
Hi xlHelp,

I know this enables me to use objects stored on those templates, but I actually want the user to be able to click on and object in the document and launch the template, which they will then edit and save as a separate file.

Any ideas?
 
Sorry, I don't know. I guess you will have to wait hear from Dreamboat or someone.

Thanks.

Indu
 
How the heck are ya, Girl? You can always email me if you wanna get me in here: Dreamboat@TheWordExpert.com

Anyway. I don't see a way to do this with a hyperlink. So what I'm thinking is you use command buttons instead. Record a macro that does the File-New to the template, and run it from a command button or a custom toolbar with buttons.

Let me know if you need help with either of those.

:) Haven't seen you in a while. Prolly my fault! Anne Troy
Dreamboat@TheWordExpert.com
Anne@MrExcel.com
 
Not sure on Hyperlinks but the following should work from a command button

To open a new Word document based on an existing template, we need to specify a value for the Template argument of the Add method of the Documents collection.

If the template file (.DOT) is saved in the UserTemplates path, we can use the pre-defined contant wdUserTemplatesPath. Otherwise, we will need to supply the complete path to the template file.


Private mobjWordApp As Word.Application

Private Sub Command1_Click()
Const conTEMPLATE_NAME = "\Templates\merge.dot"

Set mobjWordApp = New Word.Application
With mobjWordApp
.Visible = True
.WindowState = wdWindowStateMaximize
.Documents.Add Template:=(.Options.DefaultFilePath( _
wdUserTemplatesPath) _
& conTEMPLATE_NAME)
End With
End Sub

Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
Thanks for the tips, all. Ended up with the following:

Public Function LaunchTemplate(strTemplate As String, strGroup As String)
Dim strPath As String


On Error GoTo LaunchErr

strPath = "\\oa_srv1\Vol1\Group\Site\Template\"
Documents.Add Template:=strPath & strGroup & "\" & strTemplate & ".dot", _
NewTemplate:=False

LaunchExit:
Exit Function

LaunchErr:
Select Case Err.Number
Case 5151
MsgBox "Cannot locate the template!" & vbCrLf & vbCrLf & _
strPath & strGroup & "\" & strTemplate & ".dot has been moved, deleted or " & _
"renamed.", vbCritical, "Error Locating Template"
Resume LaunchExit

Case Else
MsgBox "An unexpected error has occurred!" & vbCrLf & vbCrLf & _
Err.Number & ": " & Err.Description, vbCritical, "Error Launching Template"
Resume LaunchExit
End Select
End Function

Private Sub imgBusReq_Click()
LaunchTemplate "Business Requirements", "Project Management"
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top