Microsoft KB Archive/211466

From BetaArchive Wiki

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:

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


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.


REFERENCES

For 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.



Additional query words: sr1 release1

Keywords: kbmacro kbprb kbusage KB211466