workbook stays hidden

M

Matthew Scheperle

I have part of my code below that opens the excel files, then runs a module
in the main spreadsheet. It runs correctly. I can add xl.quit and then
manually go open the file.

HOWEVER, when I try to open that same file using my code it stays hidden in
the background. I want the user to see the spreadsheet after it has done all
the formating, and other stuff to the file. It also creates a file called
BACKUP filename.xlsx which I would like to not have happen.

Ideas?
Dim xl As Object
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open filepath & "AppropAllotment2042.xlsm"

xl.Run "Module1.summarize", directory
xl.activeworkbook.Save
'xl.Quit
MsgBox directory ' This allows me to see the value assigned to directory.
Which shows the correct file path and file name.
 
M

Matthew Scheperle

Never mind. Got it.

I added xl.Visible = True .... I made the mistake of using
xl.activeworkbook.visible = True.

I missed the part where I had xl as the Excel Object and so needed to simply
make the app visible... I think. Anyway, it works.

Dim xl As Object
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open filepath & "AppropAllotment2042.xlsm"

xl.Run "Module1.summarize", directory
xl.activeworkbook.Save
xl.Visible = True

Then they can have the option of saving it to a different location,
printing, or emailing the report. Wonder if I could make it so that it will
not save anything until they are ready to do their part????

Well, not sure if this will help others.

:)
 

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

Similar Threads

Access-Excel Automation 1
Access-Excel Automation 1
VBScript help 5
format excel spread sheet 2
Excel won't go away 10
Export SQL 1
Excel Automation 1
Opening Excel Workbook from Access after TransferSpreadsheet 2

Top