heedaf
08-17-2017, 01:37 PM
I would like to create an object that is identical to
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.Sections(1).Range
End If
Debug.Print oRng.Text 'Used to verify it works
End Sub
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.Sections(1).Range
End If
Debug.Print oRng.Text 'Used to verify it works
End Sub