Removing ActiveX Controls

L

Lant

I was playing around creating masters with a CommandButton Control'
(ActiveX). I deleted the visible controls from my drawing page but I still
see a 'CommandButton2' in the VBA code editor dropdown for 'ThisDocument'. It
has 'Document' and 'CommandButton2' though there is no code associated with
it. I cannot open this drawing template and run the code associated with
'ThisDocument' . Get the Visual Basic message 'Cannot exit design mode
because control 'CommandButton2' cannot be created.
I had created the controls on a different computer and there may be
differences in the ActiveX library used. Also, I did not 'register' any
control as I now see mentioned in the VB help.
How do I go about deleting this invisible control or removing it from the
'members list' of ThisDocuments.
Any help?
 
J

junethesecond

here is a n example to delete command button.

Public Sub DeleteCommandButton()
Dim cbar As CommandBar
Dim cbtn As CommandBarButton
Dim I As Long
On Error Resume Next
Set cbar = Application.CommandBars("NameOfCommandBar")
I = InputBox("Enter Index Number.")
Set cbtn = cbar.Controls(I)
cbtn.Delete
End Sub
 
L

Lant

Thanks for the quick response.
The problem is that none of the code in 'ThisDocument' or any other macros
can be run and it gives the message 'Cannot exit design mode
because control 'CommandButton2' cannot be created. I can access the code
only if I disable the macros and open the template. Any suggestions?
 
A

Al Edlund

one technique is to save the document as XML and then use an editor to
remove the offending references, then import the corrected document.
Al
 
L

Lant

The XML technique definitely sounds like a handy workaround for this and
other situations. I got back to an older version of my code and decided to
stay away from ActiveX controls for now. Visio 2003 (maybe earlier versions
too) has Shapes called 'Common Controls'. I am now using the command buttons
from this stencil.

Thanks Everybody.

Lant
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top