View Single Post
 
Old 05-24-2012, 05:04 AM
jjfreedman jjfreedman is offline Windows 7 64bit Office 2010 32bit
Advanced Beginner
 
Join Date: May 2012
Location: https://jay-freedman.info
Posts: 39
jjfreedman is on a distinguished road
Default

The simplest way to change the arrangement of the dates is to use the Format function. I'd recommend that you look up the Help topic about this function to see all the things it can do (easy: after you type Format in the macro window, put the cursor inside the word and press F1). For this specific case, what you need is

Dim FBdate As String
FBdate = ActiveDocument.ContentControls(3).Range.Text
FBDate = Format(FBDate, "yyyy mmdd")

At that point FBDate will have the proper form, and you can use it to make a file name.

If you need to do other things with the date, such as adding days or months to it, investigate the data type named Date and the function CDate that converts strings to Date objects.
Reply With Quote