Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 13th, 2005, 05:45 AM
Authorized User
 
Join Date: Jun 2003
Location: Cape Town, Western Cape, South Africa.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Kill Excel after printing completed

I have written an application that uses an Excel template to print as follows, after populating the spreadsheet:

  'print the active sheet
  objWks.PrintOut Copies:=dblNumCopies, Collate:=True
  objWkb.Close SaveChanges:=False
  'close the objects
  Set objExcel = Nothing
  Set objWkb = Nothing
  Set objWks = Nothing


I have found however that the EXCEL object does not close when checking taskmanager. I assume that this is because the printer is busy with the sheet even after I have closed it. After the printing completed nothing closes the EXCEL object as my code has run already and the object stays open.

Is there any way that I can have my application wait on the printin to be completed before I close the object. I have tried looking at API calls to try and figure this out but the challange is to ask the printer for a message that my specific print job is completed. (This is because the printing is sent to a network printer where more than one person could be printing.

Please help.
Reply With Quote
  #2 (permalink)  
Old January 13th, 2005, 09:12 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Have you tried doing this first?

objExcel.Close


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #3 (permalink)  
Old January 13th, 2005, 10:19 AM
Authorized User
 
Join Date: Jun 2003
Location: Cape Town, Western Cape, South Africa.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have declared obj Excel as follows

   Set objExcel = New Excel.Application

It unfortunately does not have a .Close parameter. Thanks for your suggestion though!

Any other thoughts?

Bruce
Reply With Quote
  #4 (permalink)  
Old June 15th, 2006, 11:02 AM
Registered User
 
Join Date: Jun 2006
Location: Vancouver, , Canada.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

See "50 Ways to Kill Excel"
http://www.devcity.net/Articles/239/1/article.aspx
Reply With Quote
  #5 (permalink)  
Old June 15th, 2006, 04:17 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

There was a bug regarding using Word that was similar to this. There was also a very specific work-around, though I forget what that work-around was.

I have this niggling remnant of a memory that is was something like: after closing Word, using GetObject() to obtain a reference to that instance that ought not to be there, and again invoking the command to close the app.
Reply With Quote
  #6 (permalink)  
Old June 26th, 2006, 07:13 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thought it was:

objExcel.Quit(false) (The false suppresses the save dialogue)

Cheers
Joe

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
coding for printing in excel ct Excel VBA 3 August 8th, 2005 08:05 AM
Printing excel sheet siddique Excel VBA 3 February 15th, 2005 12:49 AM
Printing using EXCEL object Bruce Pro VB 6 0 January 14th, 2005 10:11 AM
Printing Excel File in ASP hkccwong Classic ASP Basics 1 January 5th, 2005 12:50 AM
export excel file and printing yyjfree Crystal Reports 0 December 13th, 2004 02:44 AM



All times are GMT -4. The time now is 03:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.