Discussion:
Macro settings problem....
(too old to reply)
praveen
2006-04-18 08:30:01 UTC
Permalink
Hi

I have developed a shared add-in in vb.net for MS Word 2003 which i am
adding a new commandbar button in "Tools" commandbars and i have written a
commandbar control event which displays a message box.

everything is working fine but after displaying a message box i am getting a
dialog box saying that "The macro caanot be found or has been disabled
because of your macro settings". Currently my macro settings are medium and i
tried even with low and i did check in "Trust all installed addins and
templates".

I did develop the same addin in couple of boxes but i am getting this dialog
box("The macro caanot be found or has been disabled because of your macro
settings") in both of the boxes.


here is the add-in code


code:
--------------------------


Public Class Connect

Implements Extensibility.IDTExtensibility2
Dim applicationObject As Object
Dim addInInstance As Object
Dim objCommandBars As Microsoft.Office.Core.CommandBars
Dim objCommandBar As Microsoft.Office.Core.CommandBar
Dim objCommandBarControl As Microsoft.Office.Core.CommandBarControl
Dim WithEvents objCommandBarButton As
Microsoft.Office.Core.CommandBarButton

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
Try
AddDocManagerMenuItem()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub



Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
Try
applicationObject.CommandBars.Item("Tools").Controls.Item("MY
Document Manager").Delete()
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub



Private Sub AddDocManagerMenuItem()

Try
objCommandBars = applicationObject.CommandBars
objCommandBar = objCommandBars.Item("Tools")

For Each objCommandBarControl In objCommandBar.Controls
If Trim(objCommandBarControl.Caption) = "MY Document
Manager" Then
objCommandBar.Controls.Item("MY Document
Manager").Delete()
End If
Next objCommandBarControl

objCommandBarButton = objCommandBar.Controls.Add(msoControlButton)
With objCommandBarButton

.Caption = "MY Document Manager"
.Tag = "MY Document Manager tag"
.OnAction = "MY Document Manager action"
.Visible = True
.TooltipText = "MY Document Manager tool tip"
End With

Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub


Private Sub objCommandBarButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles objCommandBarButton.Click
Try
MsgBox("Menu item clicked")
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

End Class




Is there any problem in code or is it to do the word settings?

Any ideas please?


cheers

Praveen
Charles Kenyon
2006-04-18 17:43:45 UTC
Permalink
Make sure your customization context is your Add-In and not normal.dot. This
is not apparent from your code. This is not what you asked about, though.

I am way too much of a novice to understand your code. I only do vba. On the
other hand, this is a vba newsgroup.

Some thoughts, though...

Do you have any references to libraries that may not be active on the other
computer?
Have you tried stepping through your code? (I'm not sure if this is possible
in vb.net.)

Try breaking the code into components and test each separately.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by praveen
Hi
I have developed a shared add-in in vb.net for MS Word 2003 which i am
adding a new commandbar button in "Tools" commandbars and i have written a
commandbar control event which displays a message box.
everything is working fine but after displaying a message box i am getting a
dialog box saying that "The macro caanot be found or has been disabled
because of your macro settings". Currently my macro settings are medium and i
tried even with low and i did check in "Trust all installed addins and
templates".
I did develop the same addin in couple of boxes but i am getting this dialog
box("The macro caanot be found or has been disabled because of your macro
settings") in both of the boxes.
here is the add-in code
--------------------------
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject As Object
Dim addInInstance As Object
Dim objCommandBars As Microsoft.Office.Core.CommandBars
Dim objCommandBar As Microsoft.Office.Core.CommandBar
Dim objCommandBarControl As Microsoft.Office.Core.CommandBarControl
Dim WithEvents objCommandBarButton As
Microsoft.Office.Core.CommandBarButton
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
Try
AddDocManagerMenuItem()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
Try
applicationObject.CommandBars.Item("Tools").Controls.Item("MY
Document Manager").Delete()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub AddDocManagerMenuItem()
Try
objCommandBars = applicationObject.CommandBars
objCommandBar = objCommandBars.Item("Tools")
For Each objCommandBarControl In objCommandBar.Controls
If Trim(objCommandBarControl.Caption) = "MY Document
Manager" Then
objCommandBar.Controls.Item("MY Document
Manager").Delete()
End If
Next objCommandBarControl
objCommandBarButton =
objCommandBar.Controls.Add(msoControlButton)
With objCommandBarButton
.Caption = "MY Document Manager"
.Tag = "MY Document Manager tag"
.OnAction = "MY Document Manager action"
.Visible = True
.TooltipText = "MY Document Manager tool tip"
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub objCommandBarButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles objCommandBarButton.Click
Try
MsgBox("Menu item clicked")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
Is there any problem in code or is it to do the word settings?
Any ideas please?
cheers
Praveen
Loading...