gsxr4fg
05-19-2018, 09:42 AM
Hello VBA Family:hi:
I am trying to automatically transfer specific Excel cells into certain locations in Word. The Excel file is named Technical Competency and the the cell is G1. In Word, I have used "Design Mode" in the Controls section to insert the element into the document, this label is named Employee. Here is the VBA script I have thus far that is giving me a Runtime 1004 error, Appication-defined or object defined error:
Private Sub CommandButton1_Click()
Dim objExcel As New Excel.Application
Dim exWb = objExcel.Workbooks.Open ("C:\Users\famison\Documents\Temp\Workplace\Technical Competency.xls")
ThisDocument.Employee.Caption = exWb.Sheets("Form Template").Cells (G1)
exWb.Close
Set exWb = Nothing
End Sub
Forgive my ignorance if the formula makes little sense, I am a newborn when it comes to writing VBA formulas.
Blessings,
Sean
I am trying to automatically transfer specific Excel cells into certain locations in Word. The Excel file is named Technical Competency and the the cell is G1. In Word, I have used "Design Mode" in the Controls section to insert the element into the document, this label is named Employee. Here is the VBA script I have thus far that is giving me a Runtime 1004 error, Appication-defined or object defined error:
Private Sub CommandButton1_Click()
Dim objExcel As New Excel.Application
Dim exWb = objExcel.Workbooks.Open ("C:\Users\famison\Documents\Temp\Workplace\Technical Competency.xls")
ThisDocument.Employee.Caption = exWb.Sheets("Form Template").Cells (G1)
exWb.Close
Set exWb = Nothing
End Sub
Forgive my ignorance if the formula makes little sense, I am a newborn when it comes to writing VBA formulas.
Blessings,
Sean