How do I change a macro to yield a variable date rather than today

A

AMG

In a Microsoft Visual Basic macro, the current command is:

myFile = Format (Now, "yyMMdd")

I would like it to use a date in a Word document form field "DOS" instead of
today's date.

How do I cnage the command so that it will recognized the date from the form
field rather than today's date?
 
G

Graham Mayor

Something like

Dim myDate As Date
myDate = ActiveDocument.FormFields("DOS").Result
myFile = Format(myDate, "yyMMdd")

should do the trick

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

AMG

Thank you so much!!!!!

Graham Mayor said:
Something like

Dim myDate As Date
myDate = ActiveDocument.FormFields("DOS").Result
myFile = Format(myDate, "yyMMdd")

should do the trick

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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