Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

VBS script problem with excel file saving

Hi all,

I'm trying to create to export a report in excel file by VBS macro and save it automatically in a particular folder..actually I´m able to create the file excel but i have always problem in saving it.

here the piece of code I use for saving the file

Const xlWorkbookNormal = -4143 '// Excel compatibility mode

Const xlWorkbookDefault = 51 '//Excel 2007

Dim fileName 'as String

fileName = "C:\Desktop\NEW QLIKVIEW PRJ\test.xls"

on error resume next

Call objExcelWorkbook.SaveAs(fileName,xlWorkbookDefault) '// or use xlWorkbookNormal

if (len(Err.Description) > 0) then

                msgbox("Error Saving Excel" & Chr(13) &  Err.Description & Chr(13) & Err.Source)

end if

on error goto 0

objExcelWorkbook.Application.Quit


In attachment you can find the entire script,


Can someone tell me please

- where is the error?

- in which point of script have to insert this?

- do you know a macro for making the same stuff but to export the file in pdf?


Thanks to all in advance for help!

13 Replies
Andrea_Ghirardello

The problem may be spaces on your path...try

wbTarget.SaveAs ("""" & vPath.getcontent.string & "\" & vFileName.getcontent.string & """")

Not applicable
Author

in save as, you may need to mention file format also..

So please mention "51" for xlsx.

For different kind of file format:

http://msdn.microsoft.com/en-us/library/office/bb241279(v=office.12).aspx

Sample code:

ExcelWorkbook.SaveAs(vPath.getcontent.string & "\" & vFileName.getcontent.string ,51)

Karthik

suhle1234
Contributor
Contributor

Hi this is not working by me:

ExcelWorkbook.SaveAs(vPath.getcontent.string & "\" & vFileName.getcontent.string ,51)

I can't give the parameter ,51, its working without.

I need to save in Format 52 with Makro enabled.

Thank you in advance for your help.

 

suhle1234
Contributor
Contributor

Working:

FileFormat=52

strpath = "\\testdrive\test.xlsm"

AppExcel.Workbooks(1).SaveAs strpath, Fileformat