Sub CreateNewWordDoc()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
docname = Worksheets("input").Range("b10").Value
Data1 = Worksheets("word").Range("a1:d103").Value
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("C:\Results\ResultsTemplate.doc")
'******THIS IS TO EDIT THE WORD DOCUMENT******
With wrdDoc
.Content.InsertAfter Data1 'this receives type mismatch
'******THIS IS THE END TO EDIT THE WORD DOCUMENT*****
If Dir("C:\Results\" & docname & ".doc") <> "" Then
Kill "C:\Results\" & docname & ".doc"
End If
.SaveAs ("C:\Results\" & docname & ".doc")
.Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
I have a worksheet labeled 'word' in my workbook. this has the data in the exact format that i want to export as. in the past - i simply have done a copy/paste into the word document but i am trying to automate this.
is there an easy way to just take the format as is and do one big data transfer as opposed to a line by line setup each with its own individual formatting?
i am still very much a novice at VBA and this is my first day working with word from within excel so please excuse any mistakes you may see as elementary
thank you
Bookmarks