[RESOLVED] Word Template in Outlook
Hello Everyone,
Sounds weird, but office politics stops me from creating a macro button through word. Plus the limitations on our network, we can't have shortcuts on our desktops.
So I was thinking, I use Outlook allot and its one of the only app that is open all the time, I've created macros for other mail templates as macro buttons, but I was thinking, why not create one for a word template I use all the time,
Here the code I've tried, but I can't get it to work the way it should, any help would be awesome. :)
Code:
Sub Faultsheet()
Set appWord = GetObject(, "Word.Application")
Set docs = appWord.Documents
docs.OpenTemplate = ("K:\AA_IT_Folder\Faults & Enquiry - Logged Calls\IT FAULT & ENQUIRY REPORTING FORM.dot")
End Sub
Re: Word Template in Outlook
Try this example which uses Latebinding...
Code:
Sub Faultsheet()
Dim oWordApp As Object, oWordDoc As Object
Dim FlName As String
FlName = "K:\AA_IT_Folder\Faults & Enquiry - Logged Calls\IT FAULT & ENQUIRY REPORTING FORM.dot"
'~~> Establish an Word application object
On Error Resume Next
Set oWordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set oWordApp = CreateObject("Word.Application")
End If
Err.Clear
On Error GoTo 0
oWordApp.Visible = True
Set oWordDoc = _
oWordApp.Documents.Open(FlName)
End Sub
Re: Word Template in Outlook
Many thanks Koolsid, as always you are the lord of VBA!:eek2:
Works like a charm, but alike my previous code, it opens the dot file, idealy id like it to open 'new template fresh' if possible?
Re: Word Template in Outlook
You mean... Replacing
Quote:
Set oWordDoc = _
oWordApp.Documents.Open(FlName)
with
Code:
Set oWordDoc = oWordApp.Documents.Add(Template:=FlName)
Also the code that I gave you in my first post, you can make the changes after you open the tmeplate and then save the word document as .Doc instead of .Dot
Re: Word Template in Outlook
Thats the puppy! Many thanks again!
Re: [RESOLVED] Word Template in Outlook