PDA

View Full Version : Solved: Save As an Excel using VB



jtrowbridge
06-10-2008, 01:31 PM
I'm trying to save an xls file with vb in excel, and I would like to specify the file as well as the directory.
I'm trying to do something like this:

Workbook.SaveAs "c:\DirectoryName\Filename.xls"

Anyone know?

:banghead:

mdmackillop
06-10-2008, 01:37 PM
Do you mean with variables for the folder and file?

jtrowbridge
06-10-2008, 01:46 PM
Yes, i can handle the variables that point to the file name and the dir, i just dont know the Save As function name or the syntax to use.

mdmackillop
06-10-2008, 01:54 PM
Sub Saves()
Dim Root As String
Dim DirectoryName As String
Dim Filename As String
Root = "C:\"
DirectoryName = "Test"
Filename = "MyTest"
ActiveWorkbook.SaveAs Root & DirectoryName & "\" & Filename & ".xls"
End Sub

jtrowbridge
06-10-2008, 01:56 PM
Killah!:beerchug: