Prompt where to save - capture user pressing cancel
Results 1 to 3 of 3

Thread: Prompt where to save - capture user pressing cancel
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular sharky12345's Avatar
    Join Date
    Aug 2010
    Posts
    3,224
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Prompt where to save - capture user pressing cancel

    I'm using this to prompt the user to save a a word document in their chosen location;

    Code:
    With Application.Dialogs(wdDialogFileSaveAs).Name = "Welfare Document - RM " & TextRM.Value
    .Format = wdFormatXMLDocument
    .Show
    End With
    If they do go on to save I need the userform to be unloaded, but the bit I am struggling with is how to simply return to the userform if they click cancel and don't save?
    There isn't a day go by without me learning something new about VBA!

  2. #2
    Board Regular
    Join Date
    Jan 2015
    Posts
    1,121
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Prompt where to save - capture user pressing cancel

    Maybe

    Code:
    If Application.Dialogs(xlDialogSaveAs).Show Then
       ' User saved
    Else
       ' User canceled 
    EndIf

  3. #3
    Board Regular
    Join Date
    Mar 2015
    Posts
    3,745
    Post Thanks / Like
    Mentioned
    66 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Prompt where to save - capture user pressing cancel

    Try this
    Code:
    Private Sub CommandButton1_Click()
        With Application.Dialogs(wdDialogFileSaveAs)
            .Name = "Welfare Document - RM " & TextRm.Value
            .Format = wdFormatXMLDocument
            If .Show Then Unload Me
        End With
    End Sub

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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