I have been attempting to export an output of an excel macro to a word document. I am able to successfully export the information I require, however am having difficulty formatting the output. I am able to format the text with a "with/end with" statement for common changes such as bold or underline, but unable to format the text as a heading. Can anyone out there direct me on how to have my output of the
Code: Select all
wdDoc.Paragraphs(ParaCount).Range = Table_2W.Range("$B" & a)
Thanks for the help, it's greatly appreciated!
Diedrich
Code: Select all
'Export Output to MS Word
'Initialize the Excel objects
Set wbBook = ThisWorkbook
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(wbBook.Path & "\" & stWordDocument)
'Add paragraph to word doc
wdDoc.Paragraphs.Add
'Count paragraphs
ParaCount = wdDoc.Paragraphs.Count
'Place heading in final paragraph
wdDoc.Paragraphs(ParaCount).Range = Table_2W.Range("$B" & a)
'Save and close the Word doc.
With wdDoc
.Save
.Close
End With
wdApp.Quit
'Null out the variables
Set wdDoc = Nothing
Set wdApp = Nothing