OrganizerCopy Problem

D

Dave

I'm trying to copy a macro from the active document to a document
which has just been created. The macro is not in the Normal.dot
template, just in the active document. The code looks like:

Dim DocA As Document, DocB As Document
Set DocA = ActiveDocument
' Create new document
Set DocB = Word.Documents.Add(DocA.AttachedTemplate.Name)
'Copy macro to new doc
Application.OrganizerCopy Source:=DocA, _
Destination:=DocB, _
Name:="CreateCustom", _
Object:=wdOrganizerObjectProjectItems

I'm having two problems: first, I get a "Run-time error '4149': File
not found" error unless the current folder for Word is the the folder
with the two documents. Second, when the current folder is set to the
folder with the two documents, I get "Run-time error: '5940': The
project item cannot be copied.

The examples I've found for this have a .dot file for the source, but
I don't know what to do in this instance.

thanks in advance, dave
 
D

Dave

I'm trying to copy a macro from the active document to a document
which has just been created. The macro is not in the Normal.dot
template, just in the active document. The code looks like:

Dim DocA As Document, DocB As Document
Set DocA = ActiveDocument
' Create new document
Set DocB = Word.Documents.Add(DocA.AttachedTemplate.Name)
'Copy macro to new doc
Application.OrganizerCopy Source:=DocA, _
  Destination:=DocB, _
  Name:="CreateCustom", _
  Object:=wdOrganizerObjectProjectItems

I'm having two problems: first, I get a "Run-time error '4149': File
not found" error unless the current folder for Word is the the folder
with the two documents. Second, when the current folder is set to the
folder with the two documents, I get "Run-time error: '5940': The
project item cannot be copied.

The examples I've found for this have a .dot file for the source, but
I don't know what to do in this instance.

thanks in advance, dave

I solved part of the problem. Changing the Source to
Source:=ActiveDocument.FullName
got rid of the "File not found" error. If anyone has thoughts on why
the macro won't copy, I will appreciate them.

thanks,

dave
 

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

Similar Threads


Top