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 ??
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 ??
Use ontime in the BeforePrint event to schedule a macro to run that will
close excel.
--
Regards,
Tom Ogilvy
"rvillanueva" <[email protected]>
wrote in message
news:[email protected]...
>
> 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
>
Try something like;
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\data\excel\TrainLoading.xlt")
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
|
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" <[email protected]>
wrote in message
news:[email protected]...
>
> 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:
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
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" <[email protected]>
wrote in message
news:[email protected]...
>
> 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
>
Thanks for your help,
Ricardo
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks