zombiemaster
Board Regular
- Joined
- Oct 27, 2009
- Messages
- 241
I found code online that I am hoping will copy from cells in a row in Excel into form fields in a Word document but I'm getting an error. Here is what I have:
I'm getting a Subscript Out Of Range error on this row:
Any ideas? I'm sure it's simple but I can't think right now...
Thanks in advance,
~ZM~
VBA Code:
Sub Transition_Test()
Dim ws As Worksheet
' Set ws = ThisWorkbook.Sheets("Billing")
Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open "C:\Users\ZM\Desktop\Word template.rtf"
With objWord.ActiveDocument
.Text1.Value = ws.Cells(Selection.Row, 8).Value
.Text2.Value = ws.Cells(Selection.Row, 5).Value
.Text3.Value = ws.Cells(Selection.Row, 4).Value
.Text4.Value = ws.Cells(Selection.Row, 6).Value
.Text10.Value = ws.Cells(Selection.Row, 22).Value
End With
End Sub
I'm getting a Subscript Out Of Range error on this row:
VBA Code:
Set ws = ThisWorkbook.Sheets("Billing")
Any ideas? I'm sure it's simple but I can't think right now...
Thanks in advance,
~ZM~