save excel filename based on Input box and allow user to select path

jaywebb846

New Member
Joined
Jun 1, 2018
Messages
12
Hi I am trying to get to a point where my users can manipulate the data then force them to create a file name based on info retrieved from an input box and allowing them to select a path and save the file to a new location. I have it sort of working but it is throwing an error a type mismatch error. Also i would like to be able to force them to use the box and not hit cancel or if they hit cancel it just goes back to the spreadsheet.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
If you have a question or need some help, post your code, tell us what you want it to accomplish and what part(s) of the code you want help on.
 
Upvote 0
If you have a question or need some help, post your code, tell us what you want it to accomplish and what part(s) of the code you want help on.

This is where I am so far. I get a type mismatch error on the section in red. Also need to know how to prevent user from just cancelling the input box or how to handle error if it is cancelled and stay in the work book

' Macro3 Macro
Dim fname As String
Dim fpath As String
'Dim file_name As Variant


'Get file name from user input
fname = InputBox("Create a Unique name to this Event or game please")
Application.GetSaveAsFilename fname
'Set current path
fpath = ActiveWorkbook.Path
If fname <> False Then
ActiveWorkbook.SaveAs ActiveWorkbook.Path '& fname & ".xls"
Set wbSource = ActiveWorkbook
MsgBox "File Saved as: " & fpath & "" & fname & ".xls"
' MsgBox "File Saved!"
End If






End Sub
 
Upvote 0
I'm a bit confused by your code. Is the input box for the user to enter a filename? If yes, will it include a file extension? Are you using GetSaveAsFilename to allow the user to determine the file path? If yes, then why are you assigning fpath to the active workbook's file path? Can you provide some more details on what you want the code to accomplish?
 
Upvote 0

Forum statistics

Threads
1,215,968
Messages
6,127,983
Members
449,414
Latest member
sameri

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