I am in the process of creating a Excel macro that takes values from a spreadsheet and creates a word documnet. I am practically done with the project but I can not get around one error when creating a shape in Word. I have created a small macro for troubleshooting wich is pasted here. I get "Object variable or With block not set on the sh = appWD.ActiveDocument.... line. Any help would be appreciated. BTW - the same code minus "appWD." works fine in a Word macro.
Sub Test3()
Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.8")
With appWD
.Visible = True
.Activate
.WindowState = wdWindowStateNormal
End With
appWD.ScreenUpdating = True
' Tell Word to create a new document
appWD.Documents.Add
'Draw Rectangle
Dim sh As Shape
sh = appWD.ActiveDocument.Shapes.AddShape(msoShapeRectangle, Left:=90, Top:=70, Width:=72, Height:=72)
End Sub
Sub Test3()
Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.8")
With appWD
.Visible = True
.Activate
.WindowState = wdWindowStateNormal
End With
appWD.ScreenUpdating = True
' Tell Word to create a new document
appWD.Documents.Add
'Draw Rectangle
Dim sh As Shape
sh = appWD.ActiveDocument.Shapes.AddShape(msoShapeRectangle, Left:=90, Top:=70, Width:=72, Height:=72)
End Sub