Thread: [Solved] Runtime error 91
View Single Post
 
Old 03-03-2011, 05:29 AM
waldux waldux is offline Windows XP Office 2010 32bit
Novice
 
Join Date: Mar 2011
Posts: 7
waldux is on a distinguished road
Default Runtime error 91

Hi,

I created userform which gives users ability to select one number from 1 to 10. After user clicks OK button, the number that he chose should be entered into the Textbox which is in the word document. This is the code that I'm using:

Code:
Private Sub CommandButton1_Click()
Dim oShape As Word.InlineShape
 
For Each oShape In ThisDocument.InlineShapes
If oShape.OLEFormat.Object.Name = "LabelA" Then
oShape.OLEFormat.Object.Caption = TextBox1.Value
End If
Next oShape
 
UserForm2.hide
End Sub
At the beginning of the day this code worked perfectly, however it started to throw error message something like 2 hours ago. Error message says that "Object variable or with block variable not set" and VBA indicates this error in the 5th line of the code (text "oShape.OLEFormat.Object.Name"). I really don't know why is this happening because I didn't change this code today and it worked fine at the start of the day.
Reply With Quote