Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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
Nextmydate = Date + 1
mydate = FormatDateTime(mydate, vbLongDate)Selection.Font.Name = "Verdana"
Selection.Font.Size = 40
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenterSelection = mydate
End Sub

Try this instead:
Private Sub Document_Open()
If ActiveDocument.Saved = False ThenFor 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 = wdAlignParagraphCenterSelection = mydate
End If
End Sub

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 = wdAlignParagraphCenterSelection = mydate
End If
End Sub

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

![]() |
word 2003 vb error 91 whe...
|
Mail merge crashes Word 2...
|

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