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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save Excel Workbook

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
hi,
the following code creates a workbook. i want to save it to "C:\TestFile\test.xls". i'm not having any luck saving this file.

i tried xl.save but i get an error "A file name 'RESUME.XLW' already exists in this location. Do you want to replace it? "

how can i code this properly?

Code:
   Dim xl As Object, xl_workbook As Object, xl_sheet As Object

   Set xl = CreateObject("Excel.Application")
   xl.visible = True 
   Set Wk = xl.Workbooks.Add

thanks
zach
 


So where is your workbook save code statement?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
ActiveWorkbook.SaveCopyAs "C:\TestFile\test.xls"
or
ActiveWorkbook.SaveAs "C:\TestFile\test.xls"
 
Code:
   Dim xl As Object, [b]xl_workbook[/b] As Object, xl_sheet As Object

   Set xl = CreateObject("Excel.Application")
   xl.visible = True 
   Set [b]xl_workbook[/b] = xl.Workbooks.Add 

   [b]xl_workbook[/b].SaveAs "C:\TestFile\test.xls"
  


Skip,
[sub]
[glasses]Just traded in my old subtlety...
[b]for a NUANCE![/b][tongue][/sub]
 
skip,

thanks for spotting this:
Set xl_workbook = xl.Workbooks.Add

didn't realize it was this simple:
Code:
xl_workbook.SaveAs "C:\TestFile\test.xls"

my original statement which was incorrect was
Code:
xl_workbook.Save

link 99sbc:
ActiveWorkbook.SaveAs "C:\TestFile\test.xls"
didn't work with extra but should work in excel

thanks again
zach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top