StephenBart
New Member
- Joined
- Jun 22, 2023
- Messages
- 15
- Office Version
- 365
- Platform
- Windows
I have built a excel loader to populate customer proposals from data in created in an excel workbook. The macro opens a mail merge word template and names it with path and filenamed based on the contents of cell values.
Macro work great but hangs in Word is already open - any idea how to fix this - i'd rather not have to close word every time Ii run the macro?
Sub CreateNewCBO()
'
' Creates CBO Onboarding Package for JPVI
'
Dim iApp As Word.Application
Dim iDoc As Word.Document
Dim FileName As String
Dim Path As String
Path = Range("c112") & "\3-CBO_Binder\"
FileName = Range("c116")
Set iApp = CreateObject("Word.Application")
iApp.Visible = True
iApp.Activate
Set iDoc = iApp.Documents.Add(Template:="U:\1000 ADMIN\1990 Templates\FORM_re_CBOName-CBO-Onboarding-Package.dotx", NewTemplate:=False, DocumentType:=0)
iDoc.SaveAs2 FileName:=Path & "000_" & FileName & ".docx", FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False
End Sub
Macro work great but hangs in Word is already open - any idea how to fix this - i'd rather not have to close word every time Ii run the macro?
Sub CreateNewCBO()
'
' Creates CBO Onboarding Package for JPVI
'
Dim iApp As Word.Application
Dim iDoc As Word.Document
Dim FileName As String
Dim Path As String
Path = Range("c112") & "\3-CBO_Binder\"
FileName = Range("c116")
Set iApp = CreateObject("Word.Application")
iApp.Visible = True
iApp.Activate
Set iDoc = iApp.Documents.Add(Template:="U:\1000 ADMIN\1990 Templates\FORM_re_CBOName-CBO-Onboarding-Package.dotx", NewTemplate:=False, DocumentType:=0)
iDoc.SaveAs2 FileName:=Path & "000_" & FileName & ".docx", FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False
End Sub