Link to home
Start Free TrialLog in
Avatar of jbotts
jbotts

asked on

VBA in Access 2007 unable to open Word 2007

Dim dirf As String
    Dim rng As Range

    dirf = MFunctions.ReadFile("CC_FileDir.txt")

    mpath = "C:\" & dirf & "\Reports\Patient-Summary-for-Bob-Smith"

    Set wo = CreateObject("Word.Application")
   
   'Add a new document
    wo.Documents.Add
   
    'To speed the document creation
    wo.ScreenUpdating = False

    Set rng = wo.Application.ActiveDocument.Range
   
    wo.WindowState = wdWindowStateMaximize
   
    'Create the Title
    With rng
        .Paragraphs.Last.Range.Style = wdStyleHeading2
        .Text = "Hello World"
    End With
      

   
    wo.WindowState = wdWindowStateMaximize
    wo.ActiveDocument.SaveAs FileName:=mpath
    wo.Visible = True
Avatar of jbotts
jbotts

ASKER

Failed to mention that using the submitted code, Word 2007 opens with the ribbon but I am unable to view the file contents. I am able to find the file in the directory where it was saved, and double click of the file will open Word normally.
Avatar of GrahamSkan
It might help if you make the application visible immediately after creating it.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland 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
SOLUTION
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
SOLUTION
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
Avatar of jbotts

ASKER

I did not select my own solution as the best solution.