The following code, when finished, is supposed to get user input of a number (here its hardcoded to 50, and doesn't focus on a specific row - it doesn't feed the data in); look up that specific row or rows in a sheet, copy a blank template of the word document, feed that data into a word document in a specific order, and then print the word document.
The code below what it tries to do is, using excel, copy a word document located at C:\original\path\here to C:\original\path\there. Unfortunately, each time I try running this in Microsoft excel, Excel hangs and then I have to restart it.
So why? What needs to be done? Microsoft word Object Library 14 is referenced in the VBA editor.
Sub UpdateActionsRows()
Dim userInput As Long
userInput = 50
' set up word application, document
Dim objWord As Word.Application
Dim objDoc As Document
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("C:\original\path\here")
copyFile objDoc, userInput
objDoc.Close
objWord.Quit
End Sub
copyfile
Function copyFile(sourceFile As Document, inputRows As Long)
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
Dim targetFile As String
targetFile = "C:\original\file\there.docx"
fso.copyFile sourceFile, targetFile
End Function