Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default 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
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Everytime i close an excel file, it creates a new backup file p Excel Discussion (Misc queries) 3 November 22nd 07 08:13 AM
Close Second Version of Excel file Sparkybird Excel Discussion (Misc queries) 1 July 24th 06 10:54 PM
File close excel does not ask me to save changes Cathy Humphreys Excel Discussion (Misc queries) 2 June 13th 05 08:48 PM
How to Close the entire Excel File Duraiswamy Lingappan Excel Programming 1 July 16th 04 11:12 AM
programmatically close help file before Excel closes? RB Smissaert Excel Programming 2 July 21st 03 11:49 AM


All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"