Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test for Cancel of SaveAs Dialog (XL2000)

    <img src=/S/newbrain.gif border=0 alt=newbrain width=21 height=22>

    I must be in need of a brain transplant, it must be the cold I have, the lack of sleep....how many excuses can I come up with?

    The following works just fine:

    SomeName = Range("I15").Value & "_" & frmForcedOutage.cboType.Value & "_" & sSaveDateValue
    Application.Dialogs(xlDialogSaveAs).Show arg1:=SomeName

    I need to test for the Cancel event from the SaveAs dialog.

    This should be very simple but my brain is mush.
    Do I use an API call?
    I can't think...

    Help Mr. Wizard

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Test for Cancel of SaveAs Dialog (XL2000)

    I think it returns True if Saved, False if Cancelled, so you can treat it as a function returning a Boolean.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test for Cancel of SaveAs Dialog (XL2000)

    INstead of using the builtin xldialogsaveas, consider using the GetSaveASFilename method. It prompts the user to enter a filename (and select a path), returns the result to VBA, But does not saveas:

    Sub GetSaveAsFileNameExample()
    Dim vFilename As Variant
    Dim sPath As String
    sPath = "c:windowstemp"
    vFilename = Application.GetSaveAsFilename(sPath & Somename, , , "Please enter a filename")
    If TypeName(vFilename) = "Boolean" Then Exit Sub
    If vFilename = "" Then Exit Sub
    ThisWorkbook.SaveAs vFilename
    End Sub
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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