word 2003 com add-in not working, visual studio 2003

R

Ratnesh Raval

Hi all,
I am writing word 2003 com add-in using visual studio 2003 vb.net

I created a shared add-in, with one CommandbarCombobox. and on change event
i am running simple code, but its not running in word.
its showing a dialog box "the macro cannot be found or has been disabled
because of your macro security settings". my macro security settings are
'medium', i've checked to trust installed and visual studio addins , and i
dont have any disabled items.(in development machine on debug and/or release
mode)

The following code creates the CommandbarCombobox (i think there is nothing
wrong in the code that trigges this behavious from word)
Thanks
---------------------------------------------------------
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
Try
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
oCommandBars = applicationObject.ActiveExplorer.CommandBars
End If
oStandardBar = oCommandBars.Item("Standard")
Try
myCombobox = oStandardBar.Controls("Custom Combobox")
Catch ex As Exception
Dim omissing As Object = System.Reflection.Missing.Value
myCombobox = oStandardBar.Controls.Add(3, omissing, omissing,
omissing, omissing)
End Try
With myCombobox
.Caption = "Custom Combobox"
.Width = 50
.Style = MsoComboStyle.msoComboNormal
.TooltipText = "custom combobox tool tip"
.Tag = "Custom Combobox"
.OnAction = "!<MyCOMAddin.Connect>"
.Visible = True
End With
'MsgBox("Started in " & applicationObject.Name & ".")
Catch ex As Exception
End Try
End Sub
 
R

Ratnesh Raval

Actually, the code inside the change event runs.
But it shows the dialog box first "the macro cannot....."
After hitting the OK button for the dialog box the code inside change event
runs
the code is showing a simple msgbox()
 
C

Cindy M -WordMVP-

Hi Ratnesh,
Actually, the code inside the change event runs.
But it shows the dialog box first "the macro cannot....."
After hitting the OK button for the dialog box the code inside change event
runs
the code is showing a simple msgbox()
How did you create the Commandbar.Combobox? Did you assign it an OnAction
property, by any chance? You'll get this message if the *VBA macro* OnAction
points to isn't available, for some reason. Seeing as how this is a .NET addin,
I'm guessing you should set the .OnAction property to "" (an zero-length
string), or don't assing it at all if you're creating the button on-the-fly).
I am writing word 2003 com add-in using visual studio 2003 vb.net

I created a shared add-in, with one CommandbarCombobox. and on change event
i am running simple code, but its not running in word.
its showing a dialog box "the macro cannot be found or has been disabled
because of your macro security settings". my macro security settings are
'medium', i've checked to trust installed and visual studio addins , and i
dont have any disabled items.(in development machine on debug and/or release
mode)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
R

Ratnesh Raval

Thanks for reply,

If you check my code, i had assigned .OnAction property
..OnAction = "!<MyCOMAddin.Connect>"
as you said i've done changes to .OnAction. and that worked.
thank you so much. it removed the dialog "the macro cannot be found or has
been ..."

but that started a new problem. after running the code inside .Change event
of CommandbarCombobox the word is crashing. (in both case, assigning
..OnAction ="" or unassigned ) . and everything works inside the Change
event but when exiting the change event it causes word to crash. If i
re-assign .OnAction property then it works without crash but with the dialog
box "the macro cannot be ...."

The following code works. no word crash------------------
Private Sub myComboBox_Change(ByVal Ctrl As
Microsoft.Office.Core.CommandBarComboBox) Handles myComboBox.Change
Try
MsgBox(applicationObject.Name)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

But the following code doesnt, it makes word crash (it shows the msgbox but
after exiting change event it crahses) -----
Private Sub myComboBox_Change(ByVal Ctrl As
Microsoft.Office.Core.CommandBarComboBox) Handles myComboBox.Change
Try
MsgBox(applicationObject.ActiveDocument.Fields.Count)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Thnx
 
R

Ratnesh Raval

Hi all,

finally i was able to solve the problem by creating another commandbar and
creating my control on that.
adding my control to "standard" toolbar was creating all these problems.
so i created new commandbar, added CommandbarCombobox to that. and
everything is working fine.
i m posting here, if anyone is facing same problem, this might help

Thanks Cindy for all the help
 
C

Cindy M.

Hi Ratnesh,
finally i was able to solve the problem by creating another commandbar and
creating my control on that.
Glad you found a way to get it to work, and thanks for sharing it here :)

Cindy Meister
 

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