OaklandJim
Well-known Member
- Joined
- Nov 29, 2018
- Messages
- 855
- Office Version
- 365
- Platform
- Windows
I am trying to assist another lister.
I thought that this would be straightforward. But. I've not worked with Word documents before. I cobbled together the code below.
When I run it Excel just sits there trying to do what I asked. But it never finishes. I get this message: Excel is waiting for another application to complete an OLE action.
I gues that I need another approach?
I thought that this would be straightforward. But. I've not worked with Word documents before. I cobbled together the code below.
VBA Code:
Sub DocFromTemplate()
Dim sPathAndFile As String
Dim oWordApp As Object
Dim oWordDoc As Object
sPathAndFile = "C:\Users\Jim\Desktop\TestTemplate.dotx" 'change to path of your file
Set oWordApp = CreateObject("Word.Application")
If Dir(sPathAndFile) <> "" Then 'First we check if document exists at all at given location
Set oWordDoc = oWordApp.Documents.Open(sPathAndFile)
End If
With oWordDoc
.SaveAs "C:\Users\Jim\Desktop\TestTemplate.docx"
End With
End Sub
When I run it Excel just sits there trying to do what I asked. But it never finishes. I get this message: Excel is waiting for another application to complete an OLE action.
I gues that I need another approach?