cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Export excell files using batch program

Highlighted
Contributor

Export excell files using batch program

Hi,

I 've got some  saved requets using to export in excell format. I want  to do these exports every night using a  batch program.

I know how to connect to my database , open my documents, but I don't know how to rewrite them executing the request and save the file.Does someone can help me?

Thanks a lot !

Sandrine

3 Replies
Highlighted
Regular Contributor

Re: Export excell files using batch program

Set xlApp = CreateObject("Excel.Application")
Set oWorkBook = xlApp.Workbooks.add
Set oSheet = oWorkBook.WorkSheets(1)

strFileName = "C:\Temp\" &  mgobjSource.GetProp("Short Name") & ".xlsx"
i = 1
oSheet.Cells(i,1).Value = <header column1>

oSheet.Cells(i,2).Value = <header column2>
i = i + 1

set colType = mgobjSource.GetCollection("<metaclass>")

    for each oType in colType
      oSheet.Cells(i,1).Value = oType.GetProp("<attribute1>")
   oSheet.Cells(i,2).Value = oType.GetProp("<attribute2>")
   i = i + 1
    next


oWorkBook.SaveAs(strFileName)

 

Highlighted
Contributor

Re: Export excell files using batch program

Thanks  a lot for your help

Highlighted
Regular Contributor

Re: Export excell files using batch program

your welcome sandrine, if you have more issues just let me know.

 

Regards

 

stijn