Application.GetSaveAsFilename isn't working

mykulpasskwa

Board Regular
Joined
Mar 20, 2018
Messages
66
Hey there, I set up an Application.GetSaveAsFilename and it successfully brings up the Save As dialogue box, however it doesn't actually save the file and the "Save as type:" only gives me the option of All Files (*.*) and won't let me select or save as .xlsm. Now I am saving this on a sharedrive, which hasn't been a problem in the past, so I'm just mentioning that but I don't think it's the cause. Anyone have any idea why it gives me the option to save but doesn't actually save the file?


VBA Code:
Sub Match()
Dim a As Currency
Dim b As Currency
Dim answer As Integer
Dim NUID As Variant

a = Worksheets("Sheet 1").Range("R24").Value
b = Worksheets("Sheet 1").Range("R25").Value
NUID = Worksheets("Sheet 1").Range("F2").Value

If b = 0 And a = 0 Then
    Exit Sub
    ElseIf Sheet2.Range("R24").Value = Sheet2.Range("R25").Value Then
    MsgBox ("The Account Balance and Banner Balance Match." & vbNewLine & "Sheet balance is $ " & a & vbNewLine & "Banner balance is $ " & b)
    answer = MsgBox("Would you like to save?", vbYesNo + vbQuestion)
    If answer = vbYes Then
    Application.GetSaveAsFilename (NUID & " - Account Overview")
    Else
        'do nothing
    End If
    End If
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
The GetSaveasFilename, only gets a name, it does not save the file. try
VBA Code:
Dim Fname As String
Fname = Application.GetSaveAsFilename(NUID & " - Account Overview")
ThisWorkbook.SaveAs Fname & "xlsm", 52
 
Upvote 0
you can get around it with:

Code:
Sub SaveAsMyWb()
Dim vFile
vFile = getSaveAsFile("c:\")
if vFile <> "" then ActiveWorkbook.SaveAs vFile, xlWorkbookDefault

End Sub



Public Function getSaveAsFile(Optional pvPath)
Dim strTable As String
Dim strFilePath As String
Dim sDialog As String, sDecr  As String, sExt As String
'===================
'YOU MUST ADD REFERENCE : Microsoft Office 11.0 Object Library, in vbe menu, TOOLS, REFERENCES
'===================
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
.Title = "Save to"
.ButtonName = "SAVE"
.InitialFileName = pvPath
.InitialView = msoFileDialogViewList 'msoFileDialogViewThumbnail

If .Show = 0 Then
'There is a problem
Exit Function
End If

'Save the first file selected
getSaveAsFile = Trim(.SelectedItems(1))
End With
End Function
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,155
Members
449,208
Latest member
emmac

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top