I am running a simple macro to paste contents from Excel range into a Word doc. It worked perfectly before but now I am getting
Runtime Error 91
Object variable or with block variable not set
The code is below.
Any ideas how to get this to run?
Sub CopyALLtoWord()
Dim objWord, objDoc As Object
ActiveWindow.View = xlNormalView
Dim i As Integer
For i = 1 To ActiveWorkbook.Worksheets("worksheet1").Cells(3, 3)
Worksheets("worksheet1").Range("n5").Value = i
Range("N5").Select
Calculate
Application.Wait (Now + TimeValue("0:00:05"))
ThisWorkbook.Worksheets("worksheet1").Range("L12:AK85").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
'Select Word & paste
Set objWord = GetObject(, "Word.Application")
objWord.Selection.Paste
objWord.Selection.TypeParagraph
Application.CutCopyMode = False
Next i
End Sub
I tried to debug and it highlighted the line objWord.Selection.Paste.
objWord.Visible = Trueright after the GetObject line, to make sure you're not using a hidden instance.