Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Autofill a form field when document opens

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nicole Kelly-Krzywonski - 12 Apr 2005 19:16 GMT
I am very new to VBA and I am trying to create an online form in which
several dates auto fill when the form is opened.  I would like to insert a
date that is 7 days prior to the current date into a form field with a
bookmark name of OnsetDate.  I created the following macro with no success:

Sub OnsetDate()
   Dim OneW as Date
   OneW=Format(DateAdd("d",-7,Date), "mm dd yyyy"
   Selection.InsertBefore OneW
End Sub

Any suggestions?

TIA
Nicole
Nicole.Krzywonski@no.spam.dshs.state.tx.us
Greg - 13 Apr 2005 03:26 GMT
Nicole,

To fire a macro when a document opens you need to use a document event
name.  To set the value of a formfield use something like:

Sub Document_Open()
 Dim OneW As Date
 OneW = Format(DateAdd("d", -7, Date), "mm dd yyyy")
 ActiveDocument.FormFields("OneW").Result = OneW
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.