StanC said:
Thanks! I'll definitely work with those.
But, what piece of code will cause those properties to appear in the
report document? Is it enough to simply put that code in a sub?
TypeText appears to accept only a string of text.
I'm a beginner and trying to do some self-teaching. Apologies for such
rudimentary questions.
Hi Stan,
It would be a bit easier to explain this if I could see the macro code you
already have, or at least the part that inserts the extracted information
you referred to.
I'll assume that your code actually opens each "source" document to extract
the data. Assuming the filename of the current source document is in the
string variable FileNm, and the cursor is in the "destination" document at
the point where the information is to be inserted, this line will put in the
name without the extension:
Selection.TypeText WordBasic.FilenameInfo$(FileNm, 4)
This will work because WordBasic.FilenameInfo$ is a function whose return
value is a string.
When you're collection information in the source document, use code like
this to get the title and store it in a string variable:
Dim Title As String
Title = ActiveDocument.BuiltInDocumentProperties("Title")
Later, when the cursor is in the destination document, use
Selection.TypeText Title
to put that string in place.
When you get more time to learn about VBA, look in the Help file and the
macro articles at
http://word.mvps.org to learn about creating Document
variables and Range objects so you can avoid moving the cursor around with
the Selection. It's much faster and more reliable that way.