+ Reply to Thread
Results 1 to 4 of 4

code to bring up the save as window

Hybrid View

  1. #1
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: open event

    You're title is misleading. Can you please edit it as per forum rules below

    Something like

    Dim Ans As String
        Ans = MsgBox("Save changes ?", _
            vbYesNo, "Save File")
     
        If Ans = vbNo Then Exit Sub ' the macro ends if the user selects the CANCEL-button
        If Ans = vbYes Then Application.GetSaveAsFilename
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  2. #2
    Registered User
    Join Date
    09-24-2008
    Location
    Las Vegas
    Posts
    12

    Re: code to bring up the save as window

    this seems to work except it doesn't save. i should also mention that im using 2007 and it needs to be accessible for 2003 users.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: code to bring up the save as window

    Maybe like this. Code goes in ThisWorkbook module.
    Private Sub Workbook_Open()
        Dim sFile   As String
        
        With ThisWorkbook
            .Saved = False
        
            If MsgBox("Save as new file?", vbYesNo) = vbNo Then .Close SaveChanges:=False
        
            sFile = Application.GetSaveAsFilename
            If sFile = "False" Then .Close SaveChanges:=False
    
            .SaveAs sFile
            If Not .Saved Then .Close SaveChanges:=False
        End With
    End Sub
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1