VBA Saving excel with some constrains

hazayah

New Member
Joined
Jul 31, 2019
Messages
2
Dear All,

I have seen the great value of this website I'm not really experience with VBAbut relaying too much on MREXCEL

i'm adding a code to for a button on the excel so when you click on it


It should openthe saving as box with a specific name reading form a cell

I found the acode but my issue is the name not showing while selecting a place to save onlyafter I save it

Please help meto re type the code properly

Thank you inadvance

Code:
Sub save_workbook()
Dim FilePath As String

ActiveWorkbook.SaveAs filename:=Range("a1"), fileformat:=52
FilePath = Application.GetSaveAsFilename
End Sub

 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try this

Code:
Dim FilePath As String
    With Application.FileDialog(msoFileDialogSaveAs)
    
        .InitialFileName = Range("A1").Value
        If .Show Then
        
            ActiveWorkbook.SaveAs Filename:=.SelectedItems(1), FileFormat:=52
        End If
    End With
 
Last edited:
Upvote 0
Try this

Code:
Dim FilePath As String
    With Application.FileDialog(msoFileDialogSaveAs)
    
        .InitialFileName = Range("A1").Value
        If .Show Then
        
            ActiveWorkbook.SaveAs Filename:=.SelectedItems(1), FileFormat:=52
        End If
    End With


thank you , it works
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

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