1

Here is the code in text form in case the image is not loading:

Sub CommandButton1_Click()
   Dim NoIO As String
   Dim shp1 As Visio.Shape
   NoIO = ComboBox1.Value

   If NoIO = "7" Then
      MsgBox shp1.ID
      'Call test(shp1)'
      'Target shape id selected'
      'Change shape data of that shape'
   End If
   Unload Me
End Sub    

Whenever I try to output the ID of a shape, I get the error:

Object variable or With block variable not set

I cannot change the parameters of the subroutine as I get a procedure declaration mismatch since this code runs after a button click on a user form.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Kamran64
  • 23
  • 4

1 Answers1

0

You have not initialised the shape shp1. You have not indicated how you are selecting your shape or why you want to select a shape so I have provided a simple example below.

Sub CommandButton1_Click()
   Dim NoIO As String
   Dim shp1 As Visio.Shape
   NoIO = ComboBox1.Value

   Set shp1 = Application.ActivePage.Shapes(1) ' Example only!

   If NoIO = "7" Then
      MsgBox shp1.ID
   End If
   Unload Me
End Sub  
AJD
  • 2,400
  • 2
  • 12
  • 22