Re: VBA code for Excel File Save As

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Khlaudhya (Khlaudhya_at_discussions.microsoft.com)
Date: 07/30/04


Date: Fri, 30 Jul 2004 01:39:03 -0700

Hi Ron,

thank you very much, this was really helpful.

Regards,

Khlaudhya

"Ron de Bruin" wrote:

> You can use GetSaveAsFilename
>
> Sub Test()
> Dim fname As Variant
> Dim Wb As Workbook
> Set Wb = ActiveWorkbook
>
> fname = Application.GetSaveAsFilename("", _
> fileFilter:="Excel Files (*.xls), *.xls")
> If fname <> False Then
> Wb.SaveAs fname
> 'Wb.Close False
> Set Wb = Nothing
> Else
> Set Wb = Nothing
> End If
> End Sub
>
>
> --
> Regards Ron de Bruin
> http://www.rondebruin.nl
>
>
> "khlaudhya" <khlaudhya@discussions.microsoft.com> wrote in message news:598B4C24-36D1-477C-8405-CB8DBD8D3512@microsoft.com...
> > Hi,
> >
> > I'm building a code where at some point I need to save the file to a new location with a specific file name, which is also
> specified by the code. I would like to be prompted for this but it only saves if I specify the path.
> >
> > This is the bit I have already written and can't go further:
> >
> > Dim NewName As String
> >
> > NewName = mRateName & " " & Validade & ".xls"
> >
> > If MsgBox("Save file as " & NewName & "?", vbYesNo, Save) = vbNo Then
> >
> > Exit Sub
> >
> > ActiveWorkbook.SaveAs FileName:=NewName
> >
> > Can anyone help me?
> >
> > Thanks
>
>
>


Quantcast