Hi, I am a novice with VBA and can certainly use some help. I have been losing hair with this. I have a button on a pop up form that merges two Word documents into one Word document. The formatting in both documents are exactly the same. When merged together, the formatting somehow gets screwed up. Mainly, the line spacing increases in some paragraphs which adds more pages to the entire merged document. Is there anyway to correct the formatting using code? Perhaps there is a better way? I would like to continue using VBA. Any help would be greatly appreciated. Here is the code I'm using.
Dim appWord As Word.Application
Dim docDocument As Word.Document
Dim SpecificFolder As Object
Dim SiteFilePath As Object
Set appWord = CreateObject("Word.Application")
With appWord
Set docDocument = .Documents.Add
.Visible = True
.Selection.InsertFile _
FileName:="C:File\MainDoc.docx", _
Link:=False, Attachment:=False
.Selection.InsertNewPage
End With
With docDocument
Set SpecificFolder = Me.SiteFolderName
Set SiteFilePath = Me.SitePathName
appWord.Selection.InsertFile _
FileName:="C:File\Site1.docx"", _
Link:=False, Attachment:=False
End With
Set docDocument = Nothing
Set appWord = Nothing
Set SpecificFolder = Nothing
Set SiteFilePath = Nothing
End Sub
Dim appWord As Word.Application
Dim docDocument As Word.Document
Dim SpecificFolder As Object
Dim SiteFilePath As Object
Set appWord = CreateObject("Word.Application")
With appWord
Set docDocument = .Documents.Add
.Visible = True
.Selection.InsertFile _
FileName:="C:File\MainDoc.docx", _
Link:=False, Attachment:=False
.Selection.InsertNewPage
End With
With docDocument
Set SpecificFolder = Me.SiteFolderName
Set SiteFilePath = Me.SitePathName
appWord.Selection.InsertFile _
FileName:="C:File\Site1.docx"", _
Link:=False, Attachment:=False
End With
Set docDocument = Nothing
Set appWord = Nothing
Set SpecificFolder = Nothing
Set SiteFilePath = Nothing
End Sub