Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Can I detect the Cancel event of SaveAs? (Word 2002)

    If Cancel is click, then dlg.Display will return False, otherwise True, so maybe <pre> blnSaved = dlg.Display </pre>

    will do the trick for you.

    Andrew C

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I detect the Cancel event of SaveAs? (Word 2002)

    I do like this just to see things clearly:

    set dlg = Dialogs(wdDialogFileSaveAs)
    With dlg
    Select Case .Display
    Case -1 'Save
    .Execute
    Case 0 'Cancel or X
    Exit Sub
    End Select
    End With
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can I detect the Cancel event of SaveAs? (Word 2002)

    <P ID="edit" class=small>Edited by gwhitfield on 06-Dec-01 22:00.</P>Cross-posted <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=wrd&Number=98275&page=&view =&sb=&o=&vc=1>here</A>

    Hi,

    I was just wondering whether it is possible to detect using VBA whether, when in the SaveAs dialog box, a user clicks on Cancel rather than Save. I need to set a blnSaved flag to false if the Cancel was selected and true if the Save was selected.

    Here is my code for SaveAs:

    Public Sub FileSaveAs()
    MsgBox "Saving..."
    Dim dlg As Dialog 'Create SaveAs dialog box
    Set dlg = Dialogs(wdDialogFileSaveAs)
    dlg.Display 'Display SaveAs dialog box
    End Sub

    Any feedback would be much appreciated <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Thanks,

    Chris

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Can I detect the Cancel event of SaveAs? (Word 2002)

    Kevin, that was a great idea to do Select Case .Display. Also, you don't need to use the dlg variable,
    <pre>With Dialogs(wdDialogFileSaveAs)
    Select Case .Display
    Case -1 'Save
    .Execute
    Case 0 'Cancel or X
    Exit Sub
    End Select
    End With</pre>

    also works and gives the clarity that you want. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I detect the Cancel event of SaveAs? (Word 2002)

    Don't need to...

    I know, but you want to show good programming practice by maintaining an "object" oriented approach...or some such nonsense.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •