GetSaveAsFilename with creating new workbook

adan96

New Member
Joined
Jul 30, 2018
Messages
7
Hello everyone,

I'm going to complete my simple application relating to creating new workbook, copying data sets from the workbook where I run my macro, pasting the set to the new one with possibility to point out a path.

Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim ans As String
Dim wrkBk As Workbook


ans = InputBox("Do You want to create raport? ")
If ans = "Yes" Or ans = "yes" Then
    Set wrkBk = Workbooks.Add
    ThisWorkbook.ActiveSheet.Copy wrkBk.Sheets("Sheet1")
    wrkBk = Application.GetSaveAsFilename(InitialFileName:=ThisWorkbook.ActiveSheet.Name, FileFilter:="Excel Files (*.xlsx), *.xlsx")
    wrkBk.Save
End If
    
End Sub

When I try to save my new workbook in my own selected path, I get the error:
"object doesn't support property or method vba"

What is wrong with the line:
"wrkBk = Application.GetSaveAsFilename(InitialFileName:=ThisWorkbook.ActiveSheet.Name, FileFilter:="Excel Files (*.xlsx), *.xlsx")"?

Thank You in advance for any suggestions.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Application.GetSaveAsFilenam returns the path/filename the user selects/enters as a string not a workbook.

You need to follow it with a SaveAs that uses that path/filename.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,205
Members
452,618
Latest member
Tam84

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