ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close a File and Excel ?? (https://www.excelbanter.com/excel-programming/360175-close-file-excel.html)

rvillanueva[_5_]

Close a File and Excel ??
 

I have a macro to print the xls file, but before i print the file i want
to close the file and the excel ??

How can i do ?? its possible ??


--
rvillanueva
------------------------------------------------------------------------
rvillanueva's Profile: http://www.excelforum.com/member.php...o&userid=28814
View this thread: http://www.excelforum.com/showthread...hreadid=537635


Tom Ogilvy

Close a File and Excel ??
 
Use ontime in the BeforePrint event to schedule a macro to run that will
close excel.

--
Regards,
Tom Ogilvy

"rvillanueva"
wrote in message
...

I have a macro to print the xls file, but before i print the file i want
to close the file and the excel ??

How can i do ?? its possible ??


--
rvillanueva
------------------------------------------------------------------------
rvillanueva's Profile:

http://www.excelforum.com/member.php...o&userid=28814
View this thread: http://www.excelforum.com/showthread...hreadid=537635




Dave Patrick

Close a File and Excel ??
 
Try something like;

Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\data\excel\TrainLoading.x lt")
xlApp.Sheets("Data").Range("e1") = readdate1
xlApp.Sheets("Data").Range("e2") = Forms!frmLoading.opt1.Value
xlApp.Run "BothPrint"
'xlApp.Application.Visible = True
xlBook.Close (False)
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"rvillanueva" wrote:
|
| I have a macro to print the xls file, but before i print the file i want
| to close the file and the excel ??
|
| How can i do ?? its possible ??
|
|
| --
| rvillanueva
| ------------------------------------------------------------------------
| rvillanueva's Profile:
http://www.excelforum.com/member.php...o&userid=28814
| View this thread: http://www.excelforum.com/showthread...hreadid=537635
|



Tom Ogilvy

Close a File and Excel ??
 
Just to add, if you have a macro in the workbook being printed that is doing
the printing, as soon as you close the workbook, the macro stops.

--
Regards,
Tom Ogilvy

"rvillanueva"
wrote in message
...

I have a macro to print the xls file, but before i print the file i want
to close the file and the excel ??

How can i do ?? its possible ??


--
rvillanueva
------------------------------------------------------------------------
rvillanueva's Profile:

http://www.excelforum.com/member.php...o&userid=28814
View this thread: http://www.excelforum.com/showthread...hreadid=537635




rvillanueva[_6_]

Close a File and Excel ??
 

Tom:

1) Im a rookie using macros, how can i do to use an event ?
Use ontime in the BeforePrint event to schedule a macro to run that
will
close excel.

2) I run the macro and when i print the sheet alway ask me for the
printer and all the normal params (copy, etc), how can i do to send in
auto way to the default printer ?

3) If i understand when i close the xls, the macro stops then the excel
still active no ??

Thanks
Ricardo


--
rvillanueva
------------------------------------------------------------------------
rvillanueva's Profile: http://www.excelforum.com/member.php...o&userid=28814
View this thread: http://www.excelforum.com/showthread...hreadid=537635


Tom Ogilvy

Close a File and Excel ??
 
See Chip Pearson's page on Events for an overview and his page on Ontime

http://www.cpearson.com/excel/events.htm

http://www.cpearson.com/excel/ontime.htm

ActiveWorkbook.Printout

or ActiveSheet.Printout

don't raise any dialogs for me.

--
Regards,
Tom Ogilvy


"rvillanueva"
wrote in message
...

Tom:

1) Im a rookie using macros, how can i do to use an event ?
Use ontime in the BeforePrint event to schedule a macro to run that
will
close excel.

2) I run the macro and when i print the sheet alway ask me for the
printer and all the normal params (copy, etc), how can i do to send in
auto way to the default printer ?

3) If i understand when i close the xls, the macro stops then the excel
still active no ??

Thanks
Ricardo


--
rvillanueva
------------------------------------------------------------------------
rvillanueva's Profile:

http://www.excelforum.com/member.php...o&userid=28814
View this thread: http://www.excelforum.com/showthread...hreadid=537635




rvillanueva[_7_]

Close a File and Excel ??
 

Thanks for your help,

Ricardo


--
rvillanueva
------------------------------------------------------------------------
rvillanueva's Profile: http://www.excelforum.com/member.php...o&userid=28814
View this thread: http://www.excelforum.com/showthread...hreadid=537635



All times are GMT +1. The time now is 09:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com