F
frank dobbelaere
Hi,
I'm new at this macro / VBA (first post here) and this has been a pretty
exciting journey so far.
Using Word 2003 I am trying to write a couple macros to automate a few
repetitive document functions. I looked at some books in the book store
(which didn't cover the subject), have printed several good tutorials
referenced frequently and prominent in google ranking (I'm sure you know the
ones I found), searched quite a bit through the help, msdn, mvp sites, ...
and have analyzed some related samples, but can't find this detail.
Goal: With this macro I would like to automate and thus standardize the
suggested file save as name. (showing the dialog to allow the user control
over the destination; so not automatically saving the file without dialog ...
at least not for the time being, a further step might be to suggest saving it
with a modified save as path that includes a subfolder based on the name, but
first things first)
Background:
I created a new template.
By the way the title of the template is set to Note, Letter, Fax - which
will be referenced as well. (this is just the first template of 3 - 4 I'm
making).
Via ASK fields it asks a few questions (Name, Number, ...) activated by an
AutoNew macro.
REF fields show the answers in the resulting document (document & header,
extra macro piece added to make sure it updates the field results in the
header).
After finishing the document I would like to use a customized Save As dialog.
The special save as ...
Created a macro which
- looks at the document properties title
- grabs the current date
and then succesfully displays a dialog as follows:
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFileSaveAs)
With dlg
..name = "_" & strDocumentType & strDate & ".doc"
..show
End With
Now, before the underscore I would like to access the value of Name and
Number; and thus suggest this name:
..name = strName & strNumber & "_" & strDocumentType & strDate & ".doc"
So, my questions is, how can I get the values of { REF Name } and { REF
Number } into strName and strNumber?
Note: With this file name idea I can ending up with very long file names, so
I am using a shorthand date and using an abbreviation for the document type;
done earlier in the macro.
An additional question comes in if it is possible to maniuplate the strName
and have the initials from {REF Name} rather than the full first name and
last name?
Or maybe it should be two ASK questions FirstName and LastName? And take the
initial from both?
Of course an additional ASK for initials would be possible; but it should be
possible to do it automatically, I think.
Thanks in advance for your help and advice.
Frank
I'm new at this macro / VBA (first post here) and this has been a pretty
exciting journey so far.
Using Word 2003 I am trying to write a couple macros to automate a few
repetitive document functions. I looked at some books in the book store
(which didn't cover the subject), have printed several good tutorials
referenced frequently and prominent in google ranking (I'm sure you know the
ones I found), searched quite a bit through the help, msdn, mvp sites, ...
and have analyzed some related samples, but can't find this detail.
Goal: With this macro I would like to automate and thus standardize the
suggested file save as name. (showing the dialog to allow the user control
over the destination; so not automatically saving the file without dialog ...
at least not for the time being, a further step might be to suggest saving it
with a modified save as path that includes a subfolder based on the name, but
first things first)
Background:
I created a new template.
By the way the title of the template is set to Note, Letter, Fax - which
will be referenced as well. (this is just the first template of 3 - 4 I'm
making).
Via ASK fields it asks a few questions (Name, Number, ...) activated by an
AutoNew macro.
REF fields show the answers in the resulting document (document & header,
extra macro piece added to make sure it updates the field results in the
header).
After finishing the document I would like to use a customized Save As dialog.
The special save as ...
Created a macro which
- looks at the document properties title
- grabs the current date
and then succesfully displays a dialog as follows:
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFileSaveAs)
With dlg
..name = "_" & strDocumentType & strDate & ".doc"
..show
End With
Now, before the underscore I would like to access the value of Name and
Number; and thus suggest this name:
..name = strName & strNumber & "_" & strDocumentType & strDate & ".doc"
So, my questions is, how can I get the values of { REF Name } and { REF
Number } into strName and strNumber?
Note: With this file name idea I can ending up with very long file names, so
I am using a shorthand date and using an abbreviation for the document type;
done earlier in the macro.
An additional question comes in if it is possible to maniuplate the strName
and have the initials from {REF Name} rather than the full first name and
last name?
Or maybe it should be two ASK questions FirstName and LastName? And take the
initial from both?
Of course an additional ASK for initials would be possible; but it should be
possible to do it automatically, I think.
Thanks in advance for your help and advice.
Frank