MS Word 2010 AutoOpen Macro to Insert Date into Text Boxes

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

LukeB12345

Thread Starter
Joined
Jul 3, 2013
Messages
41
I am trying to create an AutoOpen VBA Macro in Word 2010 files for automatically inserting the same dates into 2 different text boxes when I first open the file. Ideally, I would want 1 file to do this always for Yesterday's date (whatever that may be) and another file to do this for Friday's date (whatever that may be).

Reason for this is because our mail room gets mail the day before I get it on my desk and I need to date stamp it using a Word 2010 template where I have 2 text boxes (please see attached file--oh, doesn't seem like I can attach the file???) for Tuesday through Friday. Right now, I am using the Macros I have created (1 for Yesterday's Date and another Macro for Friday's Date which is Date() -3).

I want to use that Macro logic to put that into the Text boxes I have when it first opens? Please help me with this anyone......

It doesn't seem like I can attach the file so here is the VBA code:

Sub AutoOpen()
'
' AutoOpen Macro that places the cursor at the last position of edit (not default of top left) (will work with Protected View)
If Application.ActiveProtectedViewWindow Is Nothing Then
Application.GoBack
End If

' InsertTextBox1 Macro
Dim Shp As Shape
Set Shp = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationVertical, _
Left:=22, Top:=252, Width:=25, Height:=170)
Shp.TextFrame.TextRange.Text = "NMM RECEIVED: "
Set Shp = Nothing
Selection.InsertAfter Format(Now() - 1, "dddd, MMMM dd, yyyy")
Selection.Font.Size = 8
Selection.Font.Name = "Arial Narrow"
Selection.Font.Bold = wdToggle
Selection.Font.Bold = wdToggle

' InsertTextBox1 Macro
Dim Shp2 As Shape
Set Shp2 = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=432, Top:=752, Width:=170, Height:=18)
Shp2.TextFrame.TextRange.Text = "NMM RECEIVED: "
Set Shp2 = Nothing
End Sub


Thank you in advance,
Luke
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top