I'll be as brief as I can to not make it overcomplicated. I need to copy name and last name from Excel, paste it into Word template and print. I have a huge excel file which I need to copy two columns from each row ( ie E31:F31,E40:F40) into a bookmark in Word and then print it.
- I need to loop my script to go either from row X to Y or X number of times. The excel database is not well formated. I managed to apply paste&print to custom number of cells, but I get the "document it used do you want to open a temp copy" error probably because I try to do it all at once.
Text copied shows up in Word with big gaps between two words (what came from columen E and F), how do I fix it?
Sub Copy_Excel_Cell_to_Word_Form()
Dim wdApp As Object 'Word.Application Dim wdDoc As Object 'Word.Document For i = 31 To 60 'Open new instance of Microsoft Word Set wdApp = CreateObject("Word.Application") 'Make application visible 'wdApp.Visible = False 'Open the word document Set wdDoc = wdApp.Documents.Open("\\example.doc") 'Copy value Worksheets(1).Range("E" & i, "F" & i).Copy 'Paste to word document wdDoc.Bookmarks("WORKER").Range.PasteAndFormat (wdFormatPlainText) wdDoc.PrintOut Next
End Sub