R
Rhino
Can someone kindly remind me where macros are supposed to be put in Word
2007?
Several years ago, I had to learn quite a lot about Word macros (for Word
2002) in the space of only a few days. I put together a bunch of them and
got them all working satisfactorily. Unfortunately, I haven't had to touch
them since and I feel like I've forgotten almost everything. I've also
upgraded to Word 2007, which looks quite different in many respects to Word
2002. So I'm feeling rather clueless right now.
I want to use these macros in Word 2007. Most of them still seem to work but
I'm having some problems with at least one of them. I'll ask about that one
in a separate post. But first, can someone clarify where macros for Word
2007 are supposed to be stored?
I'm really not at all clear on whether macros belong to Word itself or are
somehow owned by individual documents.
I still have the original macros that I wrote in a text file. I can import
them via the VBA editor via File/Import File. I'm just not particularly
clear on where in the Project tree they belong.
Basically, all of these macros are used to generate my resume. I have an
external file containing data that is supposed to appear on the resume. I
use the following VB script to open the current version of the resume, then
run the master macro, createResumeFromFile, to generate the newest version
of the resume. (The data changes periodically as I emphasize/de-emphasize
various things.)
=========================
' Get arguments into variables
If WScript.Arguments.Count > 0 Then
MsgBox "Too many arguments; expecting none."
WScript.Quit
End If
' Find path for MyDocuments folder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(&H5&)
strMyDocPath = objFolder.Self.Path
' Start Word Application, open resume.doc in MyDocuments
Set oWd = CreateObject("Word.Application")
oWd.Visible = False
Set oDoc = oWd.Documents.Open(strMyDocPath & "\rhino-resume.doc")
'Run macro named createResumeFromFile, which has no arguments, and catch its
return code
retcde=oWd.Run("createResumeFromFile")
'Save changes to doc on closing and quit Word
oDoc.Save
oDoc.Close
oWd.Quit
Set oWd = Nothing
Set objShell = Nothing
'Exit the script with the value of the return code from the macro/function.
That will be zero from a successful execution or 1 otherwise.
wscript.quit(retcde)
=========================
This all worked perfectly in Word 2002 and I'm trying to set things up so
that they also work perfectly in Word 2007.
If someone can enlighten me on the proper placement of macros, I'd really
appreciate it. Also, even though these particular macros all support a
single document, it would be useful to know where to place any macros that
would be of use to other documents. Some of the macros might be useful in
other documents.
2007?
Several years ago, I had to learn quite a lot about Word macros (for Word
2002) in the space of only a few days. I put together a bunch of them and
got them all working satisfactorily. Unfortunately, I haven't had to touch
them since and I feel like I've forgotten almost everything. I've also
upgraded to Word 2007, which looks quite different in many respects to Word
2002. So I'm feeling rather clueless right now.
I want to use these macros in Word 2007. Most of them still seem to work but
I'm having some problems with at least one of them. I'll ask about that one
in a separate post. But first, can someone clarify where macros for Word
2007 are supposed to be stored?
I'm really not at all clear on whether macros belong to Word itself or are
somehow owned by individual documents.
I still have the original macros that I wrote in a text file. I can import
them via the VBA editor via File/Import File. I'm just not particularly
clear on where in the Project tree they belong.
Basically, all of these macros are used to generate my resume. I have an
external file containing data that is supposed to appear on the resume. I
use the following VB script to open the current version of the resume, then
run the master macro, createResumeFromFile, to generate the newest version
of the resume. (The data changes periodically as I emphasize/de-emphasize
various things.)
=========================
' Get arguments into variables
If WScript.Arguments.Count > 0 Then
MsgBox "Too many arguments; expecting none."
WScript.Quit
End If
' Find path for MyDocuments folder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(&H5&)
strMyDocPath = objFolder.Self.Path
' Start Word Application, open resume.doc in MyDocuments
Set oWd = CreateObject("Word.Application")
oWd.Visible = False
Set oDoc = oWd.Documents.Open(strMyDocPath & "\rhino-resume.doc")
'Run macro named createResumeFromFile, which has no arguments, and catch its
return code
retcde=oWd.Run("createResumeFromFile")
'Save changes to doc on closing and quit Word
oDoc.Save
oDoc.Close
oWd.Quit
Set oWd = Nothing
Set objShell = Nothing
'Exit the script with the value of the return code from the macro/function.
That will be zero from a successful execution or 1 otherwise.
wscript.quit(retcde)
=========================
This all worked perfectly in Word 2002 and I'm trying to set things up so
that they also work perfectly in Word 2007.
If someone can enlighten me on the proper placement of macros, I'd really
appreciate it. Also, even though these particular macros all support a
single document, it would be useful to know where to place any macros that
would be of use to other documents. Some of the macros might be useful in
other documents.