Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SaveAs Method - Save to a specific path and name

Status
Not open for further replies.

Losman500

Technical User
Oct 9, 2007
43
US
Hi, I currently have a macro that populates Excel from Attachmate. How can I save the spreadsheet filename as a value from the Attachemate screen. I had this working for a minute but it doesn't work anymore. I also would like to know if I can specify the file path to a network drive where the file will be saved. It seems to default to My Documents.

Code:
dim test 3 as string
test3 = Sess.Screen.GetString(23, 73, 8)
Objworkbook.SaveAs filename = test3
 
Hi,

In Excel, turn on your macro recorder and save as to a netword drive.

Observe your recorded code.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Wow, I feel dumb. Ok I got the Save to network path done, but I still cannot figure out how to Save as a value on my Attachmate screen.

I want the file to be save \\path\Attachmatescreenvalue.xls

Code:
Dim test3 As String
test3 = Sess.Screen.GetString(1,7,8)
 ChDir "\\FJAPPS_SERVR\common$"
 ObjWorkbook.SaveAs Filename:= "\\FJAPPS_SERVR\common$\test3.xls"
 
I figured it out. Thanks Skip for giving me a little push

Code:
test3 = ObjWorkbook.Worksheets("Sheet1").Cells(10, 10).Value
 ChDir "\\FJAPPS_SERVR\common$"
 ObjWorkbook.SaveAs Filename:= "\\FJAPPS_SERVR\common$\"&test3
 
I'm trying to save a spreadsheet as a csv file, but I can't seem to be able to do it using a variable for the filename

here is my code:

Code:
Filename = ObjWorkbook.Worksheets("Sheet1").Cells(1, 7).Value
 ChDir "C:\Documents and Settings\user\Desktop"
 ObjWorkbook.SaveAs Filename:= "C:\Documents and Settings\user\Desktop\"&Filename ,FileFormat:= xlCSV

Any ideas?
 


I just substituted my own values...
Code:
    Filename = "MyTest"
' DO NOT NEED THIS   ChDir "C:\Documents and Settings\user\Desktop"
    ObjWorkbook.SaveAs Filename:="C:\Documents and Settings\ii36250\Desktop\" & _
        Filename, FileFormat:=xlCSV
WORKS!

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I basically copied and pasted you code and still got a failure. "SaveAs method of workbook class failed".

This works:
Code:
ObjWorkbook.SaveAs Filename:= "C:\Documents and Settings\Burnside_Carlos\Desktop\My File.csv"
This doesn't:
Code:
ObjWorkbook.SaveAs Filename:= "C:\Documents and Settings\Burnside_Carlos\Desktop\My File.csv" ,  FileFormat:=xlCSV"

I still want to use the Filename variable but it doesn't work:
Code:
ObjWorkbook.SaveAs Filename:= "C:\Documents and Settings\Burnside_Carlos\Desktop\"&Filename &".csv"
I'm running Excel 2003 SP2 and Extra xtreme 9.0..what gives?
 
Never mind I got it.

I forgot the Dim Filename as String part. I feel dumb.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top