samlonergan
Board Regular
- Joined
- May 5, 2014
- Messages
- 70
Hey guys,
I'm completely stuck. I've used this macro to autofill many Word Documents, and they all work perfectly except for this one. When I run it, it opens word, but just sits there empty (i.e. no document open).
I cannot for the life of me figure it out (although my head is swimming with code at the moment, so It could be something obvious.)
I'm completely stuck. I've used this macro to autofill many Word Documents, and they all work perfectly except for this one. When I run it, it opens word, but just sits there empty (i.e. no document open).
I cannot for the life of me figure it out (although my head is swimming with code at the moment, so It could be something obvious.)
Code:
Sub QualPlan()
On Error GoTo errorHandler
Dim wdApp As Word.Application
Dim myDoc As Word.Document
Dim mywdRange As Word.Range
Dim appWord As Word.Application
Dim objWord As Word.Application
Dim CatJA As Excel.Range
Dim CatJB As Excel.Range
Dim Current As String
Current = CurDir$()
Set wdApp = New Word.Application
With wdApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set appWord = GetObject(, "Word.Application")
Set myDoc = wdApp.Documents.Open(Filename:=ActiveWorkbook.Path & "\SECTION 3 - Project Specific Quality Mgt. Plan & ITP's\Project Specific Quality Management Plan.docm")
Set CatJA = Sheets("Sheet1").Range("C12")
Set CatJB = Sheets("Sheet1").Range("C11")
With myDoc.Bookmarks
.Item("QualProjectName").Range.InsertAfter CatJA
.Item("QualClientName").Range.InsertAfter CatJB
End With
errorHandler:
Set wdApp = Nothing
Set myDoc = Nothing
Set mywdRange = Nothing
Set appWord = Nothing
ActiveDocument.Close savechanges:=True
objWord.Application.Quit wdDoNotSaveChanges
End Sub