View Single Post
 
Old 01-12-2017, 03:23 PM
Pindar Pindar is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2017
Posts: 12
Pindar is on a distinguished road
Default Macro to autofill a form field ONLY if the form field is blank upon entry

Hello, I'm new to writing macros. I'm trying to make a form that auto-fills the current date in a form field, but allows you to edit the date afterward, and I don't want it to change any date that is already in the box. Below is the macro I'm using so far. It adds the date successfully, but I don't want it to run if there is already a date in the box. What should I add?

Code:
Sub SetDate()
Dim sDate As Date
sDate = Format((Now), "MM/dd/yyyy")
ActiveDocument.FormFields("Text1").Result = sDate
End Sub
Reply With Quote