From Access.
Paul, maybe you can help me with a concept. If I change the getobject part of #8 to "set oHdr = wApp.Application.ActiveDocument.content" it seems to mimic the object created with CreateObject and seems to work ok. Why would the use of Application be required with the use of getobject? Any ideas? I'm sure you are right that there is a better way of doing this but this is all I have been able to find.
Private Sub Command0_Click()
Dim wApp As Object
Dim oRng As Word.Range
Dim lngFileNum As Long
Dim lngErr As Long
On Error Resume Next
lngFileNum = FreeFile()
Open "c:/temp/test.docm" For Input Lock Read As #lngFileNum
Close lngFileNum
filestatus = Err
If filestatus = 0 Then
Set wApp = CreateObject("Word.Application")
wApp.Documents.Open "c:/temp/test.docm"
wApp.Visible = True
Set oRng = wApp.ActiveDocument.Content
Else
Set wApp = GetObject(, "Word.Aplication")
Set wApp = GetObject("C:/temp/test.docm")
Set oRng = wApp.Application.ActiveDocument.Content
End If
Debug.Print oRng.Text 'Used to verify it works
End Sub