K
Kerri
Hi,
I am working in Word 2000 and I need to know how do I make VBA intercept the
print dialog box? If the print dialog box is clicked to be opened.... I
first want it to display a message box that asks if they want to first
update the letter Date. If they answer yes...then run the 'Date code', the
redisplay the print dialog box...Else.. Otherwise continue with the Print
dialog box. (this should only work in this template)
Here is what I have so far...but It keeps displaying the dialog instead of
intercepting it. I'm not sure if my msgbox code is accurate either. I'm
trying...but as usual I tend to hit a wall. Any help would be greatly
appreciated.
Kerri
Sub PrintMessage()
If Dialogs(wdDialogFilePrint).Display = True Then 'I also tried
..show
Dialogs(wdDialogFilePrint).hide
answer = MsgBox("Before you print, do you want to update the
document date with today's Date?")
With answer
If answer = 1 Then
UpdateBookmarkText ActiveDocument.Bookmarks("Date"),
txtDate.Text
UpdateBookmarkText ActiveDocument.Sections(1) _
..Headers(wdHeaderFooterPrimary).Range.Bookmarks("Date2"), _
txtDate.Text
Dialogs(wdDialogFilePrint).Show
Else
Dialogs(wdDialogFilePrint).Show
End If
End With
End If
End Sub
'--------------------
'
'This inserts text within the bookmark range without removing the bookmark.
Private Sub UpdateBookmarkText(BookmarkToUpdate As Bookmark, BookmarkText As
String)
Dim rngCurrentRange As Range
Dim strBookmarkName As String
Set rngCurrentRange = BookmarkToUpdate.Range
strBookmarkName = BookmarkToUpdate.Name
rngCurrentRange.Text = BookmarkText
ActiveDocument.Bookmarks.Add strBookmarkName, rngCurrentRange
Set rngCurrentRange = Nothing
End Sub
I am working in Word 2000 and I need to know how do I make VBA intercept the
print dialog box? If the print dialog box is clicked to be opened.... I
first want it to display a message box that asks if they want to first
update the letter Date. If they answer yes...then run the 'Date code', the
redisplay the print dialog box...Else.. Otherwise continue with the Print
dialog box. (this should only work in this template)
Here is what I have so far...but It keeps displaying the dialog instead of
intercepting it. I'm not sure if my msgbox code is accurate either. I'm
trying...but as usual I tend to hit a wall. Any help would be greatly
appreciated.
Kerri
Sub PrintMessage()
If Dialogs(wdDialogFilePrint).Display = True Then 'I also tried
..show
Dialogs(wdDialogFilePrint).hide
answer = MsgBox("Before you print, do you want to update the
document date with today's Date?")
With answer
If answer = 1 Then
UpdateBookmarkText ActiveDocument.Bookmarks("Date"),
txtDate.Text
UpdateBookmarkText ActiveDocument.Sections(1) _
..Headers(wdHeaderFooterPrimary).Range.Bookmarks("Date2"), _
txtDate.Text
Dialogs(wdDialogFilePrint).Show
Else
Dialogs(wdDialogFilePrint).Show
End If
End With
End If
End Sub
'--------------------
'
'This inserts text within the bookmark range without removing the bookmark.
Private Sub UpdateBookmarkText(BookmarkToUpdate As Bookmark, BookmarkText As
String)
Dim rngCurrentRange As Range
Dim strBookmarkName As String
Set rngCurrentRange = BookmarkToUpdate.Range
strBookmarkName = BookmarkToUpdate.Name
rngCurrentRange.Text = BookmarkText
ActiveDocument.Bookmarks.Add strBookmarkName, rngCurrentRange
Set rngCurrentRange = Nothing
End Sub