Save the report

N

Norek

I have a problem again, when i generate excel report i want to save it
and close the excel
Somtimes my macro working (When i open file first time, first run is ok
but next i have error: Object variable or with block variable not set)
sometimes doesn't and i dont know why , i think that problem is with
activate excel workbook but i don't know the solution


Public Sub CommandButton1_Click()
Dim EXC As Object

pth = VBA.FileSystem.CurDir

VBA.SendKeys ("{ENTER}")
Visio.Addons("VisRpt").Run ("/rptDefName=Report /rptOutput=excel")

Set EXC = Excel.ActiveWorkbook 'not always it's active :/ hmmm


EXC.SaveAs FileName:=pth + "\report.xls"
EXC.Close
Set EXC = Nothing
End Sub

Thnx for any help

Regards,
Norek
 
J

JuneTheSecond

When you open the excel workbook?
If you close it at the last part, then next time, you must open it again
next time.
 
N

Norek

Excel workbook is opening every time i press the command button ( Its
the result of the report generator addon). At the end I close excel
but nex time click it's open at the begining and didn't want to save
after open ( error ) . It's strange because when I close visio
application and run again file.vsd first click working :/. I have to
spend next few hours maby I will find the solution


JuneTheSecond napisal(a):
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top