Link to home
Start Free TrialLog in
Avatar of chestera
chestera

asked on

Open word in access 2013

Hi EE I have the following

Dim wrdApp As Word.Application
   Dim wrdDoc As Word.Document
   Dim filepath As String
    If Dir(Path) <> "" Then
           Set wrdApp = CreateObject("Word.Application")
           wrdApp.Visible = True
           wrdApp.Activate
           filepath = Path
           Set wrdDoc = wrdApp.Documents.Open(filepath)
    Else
            MsgBox ("There is no Document for this project"), vbOKOnly, "Message"
   
    End If

In access 2003 the document opens. I have migrated to access 2013 there is a minor irritant it opens minimized. I have to select the word icon on the desktop for it to open. any help appreciated

chestera
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try
Set wrdDoc = wrdApp.Documents.Open(filepath)
wrdApp.WindowState = wdWindowStateMaximize

Open in new window

Regards
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It should be like this....
Dim wrdApp As Object
Dim wrdDoc As Object
Dim filepath As String
filepath = Environ("UserProfile") & "\Desktop\MyWordDocument.docx"      'Replace the filepath as per your requirement
 If Dir(filepath) <> "" Then
        Set wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
        wrdApp.Activate
        Set wrdDoc = wrdApp.Documents.Open(filepath)
 Else
         MsgBox ("There is no Document for this project"), vbOKOnly, "Message"

 End If

Open in new window

The above code will open a word document MyWordDocument.docx saved on your desktop
Avatar of chestera

ASKER

Thanks again Ryan it's fixed
sktneer

Thank you

Alan
You're welcome Alan!