Can't record action in Word 2003 via macro?

K

KR

I apologize if this is slightly off topic, it seemed like the vba beginner
group would be the most likely to use macro recording as a starting point
for developing VBA code, and hence the best base of experts to ask this
question.

I'm recently upgraded to Office2003 (on Win2K), so this may be an easy fix,
I just can't find any relevant information.

I'm opening a file from our intranet, and don't have permission to edit the
file; so I "save as" to a local drive. I can then edit the document no
problem.

From a new "Document B", I want to record a macro, selecting the file that I
saved off the Intranet, then selecting a row, and pasting it into Document
B. I can start recording the macro in "Document B" just fine, but when I
switch to the file from the Intranet, it gives a little picture of an audio
cassette (or something like that) but won't select any rows/cells/text.

The Intranet document appears to be unprotected, because when I am not
recording a macro I can play in it directly, and because in the tool menu
the option is listed as "protect document" (whereas protected documents tend
to show "unprotect document")

I'm at a loss- what is the trick to recording actions across various open
Word files, so that I can tweak that code? Otherwise, I'm stuck trying to
learn the word object model (at least the part that deals with working with
multiple documents) from scratch, which isn't very efficient for me (at that
point it would be faster to just copy/paste each row by hand).

Thanks for any information or advice,
Keith
 
D

Dave Lett

Hi KR,

My suggested response is probably a little beyond the beginner stage, but I
think you might be able to learn from. See how the suggested code is
readable (i.e., you know what the variables refer to and you don't have to
switch bewteen an open document and back? Hope this helps:

Dim oDocDocumentB As Document
Dim oDocIntranet As Document

'''opens the Intranet document
Set oDocIntranet = Documents.Open(FileName:="C:\Test\Intranet.doc")
'''starts a new, blank document
Set oDocDocumentB = Documents.Add

'''copy the row from one document to the next
oDocDocumentB.Range.FormattedText =
oDocIntranet.Tables(1).Rows(2).Range.FormattedText

Dave
 
K

KR

Dave-

I appreciate your response; here is some additional information that might
clarify my goal(s):

the Intranet document has several tables, and what I want to be able to do
is click on a row (wishful thinking: rightclick for a custom dropdown menu)
and select TableA, TableB, or TableC. Then have the VBA copy the row
(actually, only certain cells in the row) into the "new" document, into the
next available row in the corresponding table (A, B, or C). The current
process is to select the first cell in a row, copy it over, then the third
cell from that row and copy it over, etc [to whichever table is the target
table]. The work is so repetitive that is seems a good candidate for
automation; the only human intervention needed is to judge which of the
three destination tables it would go into. So I should be starting with two
open documents, my goal is to switch between them, and (easily) select a row
and send it to the appropriate table in the "new" document.

I was thinking that recording a macro would tell me some of the pieces parts
of the object model (like your tables/rows/range below), but there are still
lots of other parts I'll need to learn to accomplish the complexity of my
task.

Any thoughts on why I can't record actions (within Word) if the active
document isn't the one I'm recording the macro in?

Many thanks,
Keith
 

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

Top