Macro to Open a Specific Word Document - Outlook 2007

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Is there an outlook macro that will simply open up a document. I have document that is in a folder and just want to open that document when I am in Outlook. The pathway to the document is : (C:\Users\UserName\AppData\Roaming\Microsoft\Templates\CalendarWordsDoc.docm). So is there a macro that will open it..and if so, please give me the full macro as soon as possible.:eek::eek::eek:
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Not clear what the full macro is.....can you post it using the location of my document?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This is all you need to open a word file -

Public Sub OpenWord()
Dim oWord As Word.Application
Set oWord = CreateObject("Word.Application")
oWord.Documents.Add Template:="C:\Invoices\template.dotm"
With oWord
.Visible = True
End With
Set oWord = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Since my document is not a template....should save it as a template?....and then the "C:\Invoices\template.dotm" i replace with "C:\Users\UserName\AppData\Roaming\Microsoft\Templates\CalendarWordsDoc.dotm). Or if not a template and just a .docm, do I change the words Add Template to something else?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It really depends on what you are doing with it. I would use a template if its something you are reusing - like to send letters to clients. If its a file, like a log or diary then opening a document is ok.

if you are using it like a template, you need to use Save as or the original will be overwritten.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Thanks ...but the word document I am opening thru the code related to it, it does certain things but is not saved......so what do I change to open the document: CalendarWordsDoc.docm??
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
use Documents.Open:

oWord.Documents.Open ("C:\Invoices\template.dotm")
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I did the following and it opens up the document....but it also opens up another folder called Documents......why is it opening a folder? Other than that, it's perfect!!!:D

Public Sub OpenWord()
Dim oWord As Word.Application
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\CalendarWordsDoc.docm")
With oWord
.Visible = True
End With
Set oWord = Nothing

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Is there an autorun macro in the word document? Only the file opens here.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The word document not as a template, as an autorun macro related to it.....and it does it all.........but it also opens up a folder
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The word document not as a template, as an autorun macro related to it.....and it does it all.........but the macro to open the documebt also opens up a folder....if I just opened the document whereever I have it, it does not open up a folder
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I have no idea - it's only opening the file here, so its nothing in the macro. Sorry.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Since the document is a macro enabled document, should we change the code so that it is recognizing the type etc......

Public Sub OpenWord()
Dim oWord As Word.Application
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open ("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\CalendarWo rdsDoc.docm")
With oWord
.Visible = True
End With
Set oWord = Nothing

End Sub


 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I fixed it as the code re the document itself had in it the automatic close of the document but then it opens up to save it....so I took he automatic close out of it, and it works....Thanks so much.....And to tell you, as a template, it doesn't run the exactly code that comes with the document....I will look into that.....and hopefully, we can solve that line space area in my other thread please!!
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
When I looked at the word code, the macro which in the module for the "normal" document, it runs from the top if Microsoft Word Opjects, This Document, and the code in that area runs he macro called SelectAllLines ....and there is an error with this when I save the document as a template.....so here is the code and what should I change on it for the template so the document created from the template runs the SelectAllLines macro

Private Sub Document_Open()
Call SelectAllLines

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
What does the macro do? You may be able to call it from the macro that opens the word document.
 

Similar threads

Top