WD2000: WordBasic MacroCopy Command Does Not Work (211466)
The information in this article applies to:
This article was previously published under Q211466 SYMPTOMS
When you attempt to use a WordBasic.MacroCopy command to copy a macro
from any location other than a local template to any location other
than a global template, the command may not work. You may receive one of the following error messages:
The project item cannot be copied
-or-
Bad Parameter
-or-
Command failed
CAUSE
You cannot copy or import a macro or module to a global template unless the template is open in Word for editing.
This functionality is by design in Microsoft Word 2000 in an effort to reduce the spread of macro viruses. This behavior is different from
Microsoft Word 97 before SR-1. In Microsoft Word 97 before SR-1, the WordBasic.MacroCopy command is executed as expected.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
To work around this behavior, use the VBComponent Export method to save your module or form as a BAS or FRM file, and then use the VBComponent.Import method to import the file into the project that you want.
For example, use the following sample code:
Sub ExportImportModule()
'Export Module1 from Normal to a BAS file
VBE.VBProjects("Normal").VBComponents("Module1").Export _
FileName:="C:\My Documents\Module1.bas"
'Import this BAS file into the desired file
VBE.VBProjects("DocProj").VBComponents.Import _
FileName:="C:\My Documents\Module1.bas"
End Sub
For additional information about VB Components.Import and .Export, click the article number below
to view the article in the Microsoft Knowledge Base:
264907 WD2000: Template Size Increases When You Add or Remove VBA Code
REFERENCESFor more information about equivalent commands in the Microsoft Word 2000 object model, click Microsoft Word Help on the Help menu, type what is wordbasic.macrocopy? in the Office Assistant or the Answer Wizard, and then click Search to view the topic. NOTE: You must be in the Visual Basic Editor before you click the Microsoft Word Help for help. For additional information about programming resources for Visual Basic for Applications, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
226118 OFF2000: Programming Resources for Visual Basic for Applications
237356 WD2000: How to Access Sample Macros for Word 2000
212536 OFF2000: How to Run Sample Code from Knowledge Base Articles
For additional information about macro viruses, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
211800 WD2000: What to Do If You Have a Macro Virus
211607 WD2000: Frequently Asked Questions About Word Macro Viruses
233396 WD2000: How to Reduce the Chances of Macro Virus Infection
For more information about macro viruses, click Microsoft Word Help on the Help menu, type macro virus in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 5/13/2002 |
---|
Keywords: | kbmacro kbprb kbusage KB211466 |
---|
|