Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 2000 Macro

Status
Not open for further replies.

scwebb

MIS
Sep 9, 2002
6
US
I have created a template in Word 2000 that I have placed
on our Intranet. I created a macro to user the Send To as
attachment feature to send this form to another user.
When the user clicks the button it gives her a macro
security error even though her Macro Security settings are
low. It runs fine on my PC (I created the form.) so I am
confused.

Is there a way to create a macro in the template instead
of as a button or menu item? I can do it in Excel but
can't seem to do that in Word.

Thanks.
 
First, what's the error?

This code creates an extra menu with 4 choices:

Private Sub Document_New()
Dim Mybar As CommandBar
Dim cmd As CommandBarPopup
Dim i As Integer
Dim A(4) As Variant

CustomizationContext = ActiveDocument.AttachedTemplate
On Error Resume Next
'Just making a dummy check to create error if menu exists
CommandBars("Menu Bar").Controls("A&nswers").Caption = "A&nswers"
If Not Err.Number = 0 Then
A(1) = Array("Do this...", "DoThis", 71)
A(2) = Array("Do that...", "DoThat", 72)
A(3) = Array("Do the other...", "DoTheOther", 73)
A(4) = Array("Do nothing...", "DoNothing", 74)
With CommandBars("Menu Bar").Controls
.Add(Type:=msoControlPopup, Before:=11).Caption = "A&nswers"
End With
For i = 1 To UBound(A)
With CommandBars("Menu Bar").Controls("Answers").Controls
Set myButton = .Add(Type:=msoControlButton)
With myButton
.Caption = A(i)(0)
.OnAction = A(i)(1)
.FaceId = A(i)(2)
End With
End With
Next i
Else
End If
End Sub

You MAY need this code if you're prompted to save the template every time someone uses it:

Private Sub Document_Close()
On Error Resume Next
ThisDocument.Saved = True
End Sub


More info:

And this is all pasted into a Word TEMPLATE (dot file).

You need to change this line:
>Dim A(4) As Variant
So that the number behind the A is the number of menu choices you have.

These lines:
>A(1) = Array("Do this...", "DoThis", 71)
Define each macro as ("Menu choice text","MacroName,Button Face ID)

I got the cool Button Face ID Add-In from John Walkenbach's site:


I copied this from an answer I gave at another tech site. The actual code was written by my partner, Oz.

Hope it helps! Anne Troy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top