macros do not work the same on different computers

C

Courtney

I created a form with macros for cascading drop-down boxes. The form works
perfectly on my PC, but if I email it to my coworkers, the macros do not
perform correctly. I have had them email the form back to me to make sure
the file did not get corrupted in the email process and it still worked as
designed on my PC. We are running the same operating system, the same
version of MS Word, and when I checked the VB version (via opening the VB
from Word and clicking Help->About) the version was the same. Does anyone
know what could possibly be causing this?
 
J

Jay Freedman

What do you mean by "do not perform correctly"? Do they work at all? If so,
what's the difference in their behavior?

Are there any error messages? If so, _exactly_ what do they say?

Does the VBA editor open with a line highlighted? If so, post the code and
indicate which line was highlighted.

If they don't work at all, the cause is probably that the code is in a
template that you aren't mailing to others, and when the form document is
mailed it loses access to the code. When the form is sent back to you, of
course you have the template, so the code runs.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
C

Courtney

No one is getting any error messages. On my computer, the cascaded drop-down
box values change when I change the selection of the top-level box
(i.e.Color). When my coworkers use the form, it only shows the values for
one of the top-level selections (Red), no matter which selection they choose
in the top-level drop-down box. I am including my code for the macro below:

Sub ColorCheck()
'
' ColorCheck Macro
' Macro created 11/19/2007 by courtney.lake
' If ActiveDocument.FormFields("Color").DropDown.Value = 0 Then
' ActiveDocument.FormFields("Change").DropDown.ListEntries.Clear
' Exit Sub
' End If
Select Case ActiveDocument.FormFields("Color").Result
Case " "
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
End With
Case " "
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
End With
Case "Brown"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Other (Provide description in Comments section below)"
End With
Case "Green"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Other (Provide description in Comments section below)"
End With
Case "Black"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Other (Provide description in Comments section below)"
End With
Case "Yellow"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Other (Provide description in Comments section below)"
End With
Case "Blue"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Other (Provide description in Comments section below)"
End With
Case "Red"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Multiplication"
.Add "Other (Provide description in Comments section below)"
End With
Case "Purple"
With ActiveDocument.FormFields("Change").DropDown.ListEntries
.Clear
.Add "Addition, Deletion, or Priority"
.Add "Multiplication"
.Add "Other (Provide description in Comments section below)"
End With
End Select

Select Case ActiveDocument.FormFields("Color").Result
Case " "
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
End With
Case "Brown"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Brown Version 1.0.0"
.Add "Other (Provide description in Comments section below)"
End With
Case "Green"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Green Version 2.0.0"
.Add "Other (Provide description in Comments section below)"
End With
Case "Black"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Other (Provide description in Comments section below)"
End With
Case "Blue"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Blue Version 3.0.0"
.Add "Other (Provide description in Comments section below)"
End With
Case "Red"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Red Version 4.0.0"
.Add "Other (Provide description in Comments section below)"
End With
Case "Purple"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Purple Version 1.0.0"
.Add "Other (Provide description in Comments section below)"
End With
Case "Yellow"
With ActiveDocument.FormFields("Version").DropDown.ListEntries
.Clear
.Add "Other (Provide description in Comments section below)"
End With
End Select
End Sub
 
J

Jay Freedman

Can you tell for sure whether the macro is running at all? Is it possible
that what the other users are seeing is just the default that appears when
the macro doesn't run?

To test, modify the macro so the first executable line after the Sub
ColorCheck() line is a message box, something like

MsgBox "Executing ColorCheck"

When you use the form on your computer, you'll see this message box before
the values change, and it'll wait for you to click OK. Now mail the form to
someone else. Do they also see the message? If not, then the macro isn't
being run. As I said before, the most likely cause is that the macro is in a
template that the recipients don't have.
 
C

Courtney

I think the macros are being run because when my coworkers are opening the
form, Microsoft asks them if they want to enable macros. They are clicking
enable, so I think it is running. I will use your method to check tomorrow,
as my coworkers have already left for the day. Thank you so much for your
help.
 
R

Rob

I think the macros are being run because when my coworkers are opening the
form, Microsoft asks them if they want to enable macros. They are clicking
enable, so I think it is running.

So you're certain they are enabling macros?

How does this ColorCheck get executed? Is it from a Document_New event and
are they actually doing new or opening it?
 
C

Courtney

Okay, you are right, the macros are not being sent. Can you help me with
what I need to do to make sure the macros are included when I send the form?
Thank you!!!
 
J

Jay Freedman

OK, this is where the story gets really complicated.

You _can_ copy the macros into the document that's being sent. (You can
either copy/paste the code from the template into the document in the VBA
editor, or use the Organizer [Tools > Macro > Macros > Organizer] to move
the whole module.)

The problem is that as soon as Microsoft allowed macros to be saved in
documents, it took about 5 minutes for the scumbags of the world to write
viruses as macros and send them out to infect and destroy. As defense,
Microsoft had to put in a mechanism to stop unknown macros from running. At
Tools > Macro > Security, there are various levels ranging from Low (don't
catch anything, which is Not Recommended) to Very High (almost complete
interdiction). Most people keep the default level of High, which disables
any macros that don't have a digital security signature.

To email a document containing macros and expect the macros to run, you need
to sign the macros. First you need a security certificate. There are several
kinds.

- The "gold standard" is one issued by a Root Authority such as Verisign
(https://securitycenter.verisign.com/celp/enroll/retail) or Thawte
(https://www.thawte.com/ssl-digital-certificates/code-signing/codesign_technical.html),
but these cost big money. If your company has a certificate server, you may
be able to get one more easily.

- For more casual use, you can generate a certificate for yourself, although
it won't be as trustworthy as a root-derived certificate. Run the program
SelfCert.exe in the same Office folder that contains the WinWord.exe program
(location depends on the Office version).

Once you have a certificate, and you've copied the macros into the document
in the VBA editor, click Tools > Digital Signature > Choose. Select the
signature, click OK, and save the document.

When a recipient opens the form for the first time, they'll be asked to
accept the certificate. Your email should tell them to do so. After that,
the form and any other documents signed with the same certificate will open
without macro security warnings if the recipient's security level is High or
less. (If it's Very High, they'll have to save the document to a "trusted
location" first. That's a whole other story.)

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
C

Courtney

Sorry it has taken me so long to post but we have had some network issues
over here. Your latest post was exactly what I needed, thank you so much for
your help. I truly appreciate the help you have given me.

Jay Freedman said:
OK, this is where the story gets really complicated.

You _can_ copy the macros into the document that's being sent. (You can
either copy/paste the code from the template into the document in the VBA
editor, or use the Organizer [Tools > Macro > Macros > Organizer] to move
the whole module.)

The problem is that as soon as Microsoft allowed macros to be saved in
documents, it took about 5 minutes for the scumbags of the world to write
viruses as macros and send them out to infect and destroy. As defense,
Microsoft had to put in a mechanism to stop unknown macros from running. At
Tools > Macro > Security, there are various levels ranging from Low (don't
catch anything, which is Not Recommended) to Very High (almost complete
interdiction). Most people keep the default level of High, which disables
any macros that don't have a digital security signature.

To email a document containing macros and expect the macros to run, you need
to sign the macros. First you need a security certificate. There are several
kinds.

- The "gold standard" is one issued by a Root Authority such as Verisign
(https://securitycenter.verisign.com/celp/enroll/retail) or Thawte
(https://www.thawte.com/ssl-digital-certificates/code-signing/codesign_technical.html),
but these cost big money. If your company has a certificate server, you may
be able to get one more easily.

- For more casual use, you can generate a certificate for yourself, although
it won't be as trustworthy as a root-derived certificate. Run the program
SelfCert.exe in the same Office folder that contains the WinWord.exe program
(location depends on the Office version).

Once you have a certificate, and you've copied the macros into the document
in the VBA editor, click Tools > Digital Signature > Choose. Select the
signature, click OK, and save the document.

When a recipient opens the form for the first time, they'll be asked to
accept the certificate. Your email should tell them to do so. After that,
the form and any other documents signed with the same certificate will open
without macro security warnings if the recipient's security level is High or
less. (If it's Very High, they'll have to save the document to a "trusted
location" first. That's a whole other story.)

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Okay, you are right, the macros are not being sent. Can you help me
with what I need to do to make sure the macros are included when I
send the form? Thank you!!!
 

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