I have some code that copies a toolbar, autotext and macros to the existing document. However, if the macros already exist in the document, I get an error message (Runtime 5940 – the project item cannot be copied). I don’t know how to check to see if the toolbar, macros and autotext entries already exist in the current document. Here’s a portion of the code:
Sub CopyMacros()
Dim strThisDocument As String
strThisDocument = ActiveDocument.FullName
Application.OrganizerCopy Source:= _
“C:Program FilesMicrosoft OfficeTemplatesFirm GeneralFirmLtr.dot”, _
Destination:=strThisDocument, Name:=”Firm Letter”, _
Object:=wdOrganizerObjectCommandBars
Application.OrganizerCopy Source:= _
“C:Program FilesMicrosoft OfficeTemplatesFirm GeneralFirmLtr.dot”, _
Destination:=strThisDocument, Name:=”PrintLetter”, _
Object:=wdOrganizerObjectProjectItems
Application.OrganizerCopy Source:= _
“C:Program FilesMicrosoft OfficeTemplatesFirm GeneralFirmLtr.dot”, _
Destination:=strThisDocument, Name:=”PrintLabel”, _
Object:=wdOrganizerObjectProjectItems
Application.OrganizerCopy Source:= _
“C:Program FilesMicrosoft OfficeTemplatesFirm GeneralFirmLtr.dot”, _
Destination:=strThisDocument, Name:=”PrintEnvelope”, _
Object:=wdOrganizerObjectProjectItems
End Sub
There is also probably a much more streamlined way to effect each copy but I’m quite a novice at this stuff so please bear with me. Thanks for any assistance.