Computing.Net > Forums > Office Software > vb question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

vb question

Reply to Message Icon

Name: fight
Date: July 5, 2006 at 08:11:16 Pacific
OS: windows xp
CPU/Ram: p4/512
Product: intel
Comment:

Everytime i save the document and reopen it, it will generate a date for tomorrow. So basically if i save the document 5 times and reopen it, it will have 5 dates in it. Is there a way i could have 1 date showing only no matter how many times i save and open the document

thanks

Private Sub Document_Open()

For x = 1 To 20
Selection.TypeParagraph
Next

mydate = Date + 1
mydate = FormatDateTime(mydate, vbLongDate)

Selection.Font.Name = "Verdana"
Selection.Font.Size = 40
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

Selection = mydate

End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: rhawk7938
Date: July 5, 2006 at 18:45:03 Pacific
Reply:

Try this instead:

Private Sub Document_Open()


If ActiveDocument.Saved = False Then

For x = 1 To 20
Selection.TypeParagraph
Next


mydate = Date + 1
mydate = FormatDateTime(mydate, vbLongDate)

Selection.Font.Name = "Verdana"
Selection.Font.Size = 40
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

Selection = mydate

End If

End Sub


0

Response Number 2
Name: fight
Date: July 6, 2006 at 03:59:23 Pacific
Reply:

thanks again rhawk...but this time the page is blank...


0

Response Number 3
Name: rhawk7938
Date: July 6, 2006 at 11:31:21 Pacific
Reply:

Sorry about that my mistake, how about just a simple message box asking: Insert Date yes/no?

Private Sub Document_Open()

answer = MsgBox("Insert Date??", vbYesNo)
If answer = vbYes Then


For x = 1 To 5
Selection.TypeParagraph
Next


mydate = Date + 1
mydate = FormatDateTime(mydate, vbLongDate)

Selection.Font.Name = "Verdana"
Selection.Font.Size = 40
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

Selection = mydate

End If

End Sub


0

Response Number 4
Name: fight
Date: July 6, 2006 at 19:19:47 Pacific
Reply:

Thanks for the help. The pop-up box works fine but it will not remove/delete the old date (same as before) once the file is save and reopen
sorry about this


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


word 2003 vb error 91 whe... Mail merge crashes Word 2...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: vb question

Access VB question!!!??? www.computing.net/answers/office/access-vb-question/3686.html

VB question-excel www.computing.net/answers/office/vb-questionexcel/4935.html

Excel VB open hyperlink www.computing.net/answers/office/excel-vb-open-hyperlink/9364.html