Microsoft KB Archive/211466

= WD2000: WordBasic MacroCopy Command Does Not Work =

Article ID: 211466

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



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.



WORKAROUND
Microsoft 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:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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



MORE INFORMATION
The following table details how the WordBasic.MacroCopy, WordBasic.Organizer, and Application.OrganizerCopy commands perform in Microsoft Word 2000.

NOTE: "Global Temp" indicates any template loaded globally (that is, it is loaded by clicking Templates and Add-Ins on the Tools menu).

An error message is generated when you try to perform any of the illegal copies. The error message changes, depending on the command that you use and the target.

WordBasic.MacroCopy
  Source       Target        Valid  Err  Error Message Document    Document      Yes Document    Template      Yes Document    Normal        Yes Document    Global Temp   No*    24   Bad Parameter Template    Document      Yes Template    Template      Yes Template    Normal        Yes Template    Global Temp   No*    24   Bad Parameter Normal      Document      No     24   Bad Parameter Normal      Template      No     24   Bad Parameter Normal      Normal        No     24   Bad Parameter Normal      Global Temp   No     24   Bad Parameter Global Temp Document      No     24   Bad Parameter Global Temp Template      No     24   Bad Parameter Global Temp Normal        No     24   Bad Parameter Global Temp Global Temp   No     24   Bad Parameter

WordBasic.Organizer
  Source       Target        Valid  Err  Error Message Document    Document      Yes Document    Template      Yes Document    Normal        Yes Document    Global Temp   No*    1844 The project item cannot be copied Template    Document      Yes Template    Template      Yes Template    Normal        Yes Template    Global Temp   No*    1844 The project item cannot be copied Normal      Document      No     102  Command failed Normal      Template      No     102  Command failed Normal      Normal        No     102  Command failed Normal      Global Temp   No     102  Command failed Global Temp Document      No     102  Command failed Global Temp Template      No     102  Command failed Global Temp Normal        No     102  Command failed Global Temp Global Temp   No     1844 The project item cannot be copied

Application.OrganizerCopy
  Source       Target        Valid  Err  Error Message Document    Document      Yes Document    Template      Yes Document    Normal        Yes Document    Global Temp   No*    5940 The project item cannot be copied Template    Document      Yes Template    Template      Yes Template    Normal        Yes Template    Global Temp   No*    5940 The project item cannot be copied Normal      Document      No     4198 Command failed Normal      Template      No     4198 Command failed Normal      Normal        No     4198 Command failed Normal      Global Temp   No     4198 Command failed Global Temp Document      No     4198 Command failed Global Temp Template      No     4198 Command failed Global Temp Normal        No     4198 Command failed Global Temp Global Temp   No     5940 The project item cannot be copied NOTE: You can copy from a document or template to a global template if the global template is open in Word for editing.

