Remove the line "Dim paneltype As Variant" from the second procedure.
Read the VBA help article "Understanding Scope and Visibility". After
that you may understand that the declaration of a local variable
inside CommandButton2_Click makes the global variable of the same name
invisible to any code inside that procedure. Therefore, that procedure
defines a value for the local variable but leaves the global variable
without a value.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>I am trying to select a variable in one sub procedure and then use that
>variable in another procedure. I am using the following code:
[quoted text clipped - 27 lines]
>commanbutton1 it is supposed to insert the picture, although it has trouble.
>Any ideas?