Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Detecting If Excel And Word Has Finished Their Print Jobs

Hi all,
I have a vb app that prints a list of word and excel documents.

The printing works just fine, but I need to know when Word and Excel has finished the print jobs I sent to them, in order to close the applications(word and excel).

If I use the Application.Quit methode, the users of my app sometimes get the message saying : "Word is currently printing. Quitting Word will cancel all pending print jobs........."

I don't want the users to see this message, but I have not found any other way of making sure that Word and Excel has shut down, than to use the Quit methode.

So, in order for me to use the Application.Quit, I need a way to determine if the print jobs has finished.

All suggestions are very very very welcome.


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Can I Reduce The Wastage Of Paper After Printer Jobs Finished
hai all,

 i am using crystal report 8.0 in my VB projects.i want to print a bill . The output in the printer was fine.But i have small problem in the bill paper , after print the data , printer running Continuously for few seconds. i got some wastage of paper after printer jobs finished.there is a lot of waste space came out in the bill paper.

 Please give good ideas or guidelines for me to solve this problem

Monitoring Print Port And Duplicating Print Jobs
Hello Everyone,

I need some help please, Im working on a domain server, as you can see the image attached, this is my network layout... Now from there, I have it where my station 1-4 have there own printers and I want it that anything they print to be duplicated and to be printed on the laser printer.. basiclly all orders being printed from front counter, a second copy to be printed in the back office... I can't find any software that will do this, but someone told me what i can do is create a custom program to monitor the print ports, and any print thats send from the stations to send it to the network printer as a duplicate copy... can any1 help me with this.. I would really appricate it.

Thank You

Detecting If 3rd Part Program Is Finished
Hi there.

Is there a way in VB to detect if a 3rd party program has finished processing in the background?

my app is running - calls a 3rd party app, and i want to know if it has finished processing the 3rd party up so i can then say in VB something like "msgbox("Process complete")"


Detecting When MMControl Sound File Is Finished
How can I tell when a sound file being played with the MMControl is done and then start playing another sound file? "If MMControl1.Position >= MMControl1.Length Then" does not work..

Media Player Control - Detecting Finished Playback
How do you find out whether or not a song has finished playback? I tried the EndOfStream sub but that didnt work

Problems Detecting Frames Finished Loading Using Document_Complete
Does anyone know how to detect when a specific frame has finished loading via the Document_Complete event? I'm currently using code similar to what I've printed below, but it only works on 9x and NT 4 machines. For some reason, the second "if" statement doesn't fire in Win2000. I guess what I'm looking for is, can anybody tell me why this might be? and Is there a better way of doing this? I've tried waiting for specific URL's, but I don't think that it is a good solution. help!

Private Sub brwWebBrowser_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        If (pDisp Is brwWebBrowser.Object) Then
            msgbox "Web document is finished downloading"
            Exit Sub
        End If
        If (pDisp.Document Is brwWebBrowser.Object.Document.frames(1).Document) Then
            msgbox "Second Frame is finished downloading"
        End If
    End If
End Sub

Print Jobs
Is there is way for me to get the filename and path of the file being printed?

Print Jobs
Is there a way to delete jobs from the print queue, either selectively or all of them? I am able to populate a ListView box with all the print jobs in the queue for a certain printer, but I need to be able to delete them also. Any ideas?

Print Jobs Through A Network
Hi people,

When I send my print jobs through a network using a self-written software, it appears as ¡®Remote DownLevel Document¡¯ on the other side , I was wondering if this is normal?
I don¡¯t mind the details of the job missing , but I just wish to know does that mean my original file is corrupted/virus or something..

All I need is for the job to print correctly..

Will it?

Thanks =)


Control Print Jobs
Hi guys,

Please, I need my app to control print activities going on, on the local machine where the app is installed. I looked around for an activex control with that functionality but found none. Is there a specific place I can look? Thanks.

Queue Print Jobs
Is it possible to "save" or queue print jobs before sending them to the printer?

I use:
Printer.PaintPicture PicBox2.Picture, 0, 0
to print a form. it takes about 15 seconds (novell print queue). when I print multipls forms (same form/different data), I have to wait 15 seconds, then go to another record and print again.

If I could save the jobs and only send them to the printer at the end, I could go do something else while it prints.


Delete Print Jobs
Would any of you know how I would begin to delete a print job from VB?



Sending Print Jobs Through LAN
Hi, can anyone help me on this?

I am trying to write a VB script to allow me to send print jobs to printers connected directly to PC in a local area network, but unsuccessful so far.

The logic of the script goes something like this:-

Match the computer name in the network. If can't find create a log and skip to next computer name.If yes, send print job down to PC and print through it printer port.Repeat until end of list.

However, it has been unable to send the print jobs through yet.Not sure what else i need to do. Appreciate any help given.


Capturing Print Jobs
I've been asked to create a piece of software that listens for print jobs, captures them when they occur, modifies them, and then puts them into the print queue.

The software needs to listen for print jobs because another piece of software dynamically creates a word document and prints that document without a chance for the user to modify the document. I cannot modify that other software, so the only chance to change the document is before it reaches the print spooler.

The printer is a network printer, and the software is to run on the client side. I think this means that I cannot take jobs out of the queue itself because the queue is on the server.

Anyway, I don't exactly know how to listen for print events, and capture them when they occur. If anyone has any suggestions or functions for this, I am all ears.

Monitor Print Jobs Using VB 6
Does anyone know of a way to monitor print jobs? We need to bill our client per print jobs. If someone makes a print out for a client that company should be billed for it. information should be sent to a report. Thanks

Print Jobs Redirection
Hi All,

I am currently researching how to redirect print jobs waiting in the print queue to another printer by simply "right click" on the document and "send" it to other printer already installed on the system. Is there any way of doing it with VB or some other languages?

Thank You All!!

Michael L. Chu, Deloitte & Touche
Tel: 416-601-6150 x 7651 Fax: 416-601-6151

Print Jobs Redirection
Hi All,

I am currently researching how to redirect print jobs waiting in the print queue to another printer by simply "right click" on the document and "send" it to other printer already installed on the system. Is there any way of doing it with VB or some other languages?

Thank You All!!

Michael L. Chu, Deloitte & Touche
Tel: 416-601-6150 x 7651 Fax: 416-601-6151

Cacthing Print Jobs
Hi all,
I want to catch all the print jobs (from any application) before they execute to the printer.
how can I catch them and use the print job information in my VB app.

Print Jobs Through A Network
Hi people,

When I send my print jobs through a network using a self-written software, it appears as ¡®Remote DownLevel Document¡¯ on the other side , I was wondering if this is normal?
I don¡¯t mind the details of the job missing , but I just wish to know does that mean my original file is corrupted/virus or something..
All I need is for the job to print correctly..

Will it?

Thanks =)


Checking Print Spooler For Jobs In VBA
I have a program that prints reports in access automaticly. It sends jobs to the current default printer. That printer is a network printer installed ont he local machine.

I want to check the print spooler to be sure the report finished printing. By print spooler, I mean the icon that looks like a printer in the task bar. When clicked on, it shows any pending jobs.

Basicly, I want to check this for any jobs, and read their names, how many pages the report is, etc.

I have ZERO code at this point, because I don't know how to reference that object or whatever it is called. I stried searching here and on google, but aparently, my searching skills are limited. I find it hard to believe no one has ever asked this question before

Shellexecute Ordering Print Jobs
I am using the shellexecute command to batch print a list of files in a list box by name. The routine is sending all of the files to the printer, but I need for them to be in order as listed in the list box.

The files are all different sizes, and shellexecute seems to be moving to the next file while the previous is spooling. How can I ensure that the order is as they appear in the listbox?

Here is the code I am using for shellexecute:

Dim i As Integer
For i = 0 To Form2.List1.ListCount - 1
Call ShellExecute(hwnd, "Print", (Form2.List1.List(i)), "", "", 0)
Next i

Thanks for any help.

Delete All Jobs From Print Spooler
I have 3 printers attached to a server. From one of the printer I want to delete all the jobs from print spooler from windows 2000. I tried printer.killdoc. I couln't succeed.

Could you please let me know how can I delete all the jobs.

cud u reply to my in urgent need of this concept


Producing Large Print Jobs In VB
I need to produce a large number of customer statements from within a Visual Basic application - 50,000 customers at 2 pages per customer = 100,000 total pages. I need to be able to both send the pages to a printer but also save them to file. My normal report writer, Crystal Reports, seems totally incapable of dealing with this volume. Does anyone have any recommendations for tools/technologies to deal with large printing needs in the client/server environment?

Print Jobs Monitor(still Unsolved)
Hi I work on a project and I want to count how many times a user made a print.For example if he press two pages of a word file the program counts "2" . Is there any way that I count them?????

Edited by - rippergr on 3/11/2004 4:34:57 AM

Countiing Print Jobs.. Very Urgent
Hai guys...
Can any body Help me out this problem...
I need to keep track of the print jobs given by all applications in the system. In brief I want to count the total number(Pages) of printouts taken.
Is it possible in VB to do that

Moving Jobs Between Print Queue
Hi all,

I'm a newbie in VB 6.0 and I'm trying to develop a system for my workplace where users have to authenticate before they are allowed to print.

I've searched all the posting and I found one post by kdevine about setting up a dummy printer that is always paused on the printer server and when user authenticate the system will move the print job from the dummy printer queue to the real printer queue.

But I'm having trouble understanding how to move the print job. I've read somewhere that you can use file copy to it.

Can someone point me in the right direction?




Excel Closes, But Word Doesn't! And Word Won't Print!
   My code needs to open Excel, populate a table with data, mail-merge that table with a Word document, and finally print the merged documents. I have two problems:

1) As the program finishes, Excel closes and is removed from the Task Manager's Processes list, but Word is not removed. I've tried the .Quit method for both (even accounting for Word's use of parameters), but "WINWORD.EXE" remains on the list even after "EXCEL.EXE" is removed. I also set my objects to Nothing in Class_Terminate, but still no luck - and putting the .Close/.Quit procedures under Class_Terminate gave me an error. I know Excel is working because the program is saving my .xls files, but I'm not sure about Word. Which leads to...

2) Obviously I'm only opening Word to merge the file - the text of the document itself never changes so it doesn't need to be saved, just linked to the data source (the Excel table just created). But I can't get Word to print! I set the .ActivePrinter property and used .PrintOut but no luck. What do I have wrong here? Thanks for any insight.

Jeff W.
Owen, Little and Assoc., Inc.
Beachwood, NJ

P.S. This code runs from within ArcMap, a digital-mapping software package. Hence all of the "ICommand"s and "IMap"s and such, the use of "ISelectionSet" to populate the Excel table, etc. All of the code pertaining to ArcMap works fine - it's mostly just the part at the end of the code relating to Word where there must be something I'm doing wrong.

Code:Option Explicit

Implements ICommand

Private m_pApp As IApplication                                         
Private m_pMxDoc As IMxDocument
Private m_pMap As IMap
Private m_pExt As IExtension
Private m_pFeature As IFeature
Private m_pFeatureLayer As IFeatureLayer
Private m_pFeatureCursor As IFeatureCursor
Private m_pFeatureSelection As IFeatureSelection
Private m_pSelectionSet As ISelectionSet
Private m_pFields As IFields
Private m_pField As IField
Private m_pRow As IRow
Private m_pCursor As ICursor
Private m_pQBLayer As IQueryByLayer
Private m_pBitmap As IPictureDisp

Private m_pAppExcel As New Excel.Application
Private m_pWorkbook As Excel.Workbook
Private m_pWorksheet As Excel.Worksheet

Private m_pAppWord As New Word.Application
Private m_pDocument As New Word.Document
Private m_pMailMerge As MailMerge

Private Sub Class_Initialize()
   Set m_pBitmap = LoadResPicture(101, vbResBitmap)         'Button icon
End Sub

Private Sub Class_Terminate()
   Set m_pApp = Nothing
   Set m_pMxDoc = Nothing
   Set m_pMap = Nothing
   Set m_pExt = Nothing
   Set m_pFeature = Nothing
   Set m_pFeatureLayer = Nothing
   Set m_pFeatureCursor = Nothing
   Set m_pFeatureSelection = Nothing
   Set m_pSelectionSet = Nothing
   Set m_pFields = Nothing
   Set m_pField = Nothing
   Set m_pRow = Nothing
   Set m_pCursor = Nothing
   Set m_pQBLayer = Nothing
   Set m_pBitmap = Nothing

   Set m_pAppExcel = Nothing
   Set m_pWorkbook = Nothing
   Set m_pWorksheet = Nothing

   Set m_pAppWord = Nothing
   Set m_pDocument = Nothing
   Set m_pMailMerge = Nothing
End Sub
'ICommand members
Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE
   ICommand_Bitmap = m_pBitmap
End Property

Private Property Get ICommand_Caption() As String
   ICommand_Caption = "200' List"
End Property
Private Property Get ICommand_Category() As String
   ICommand_Category = "Extending ArcObjects"
End Property

Private Property Get ICommand_Checked() As Boolean
   ICommand_Checked = False
End Property

Private Property Get ICommand_Enabled() As Boolean
   ICommand_Enabled = True
End Property

Private Property Get ICommand_HelpContextID() As Long

End Property

Private Property Get ICommand_HelpFile() As String

End Property

Private Property Get ICommand_Message() As String
   ICommand_Message = "Creates a 200' list for selected property and generates an Excel file (for mail merge)"
End Property
Private Property Get ICommand_Name() As String
   ICommand_Name = "ExtendingArcObjects_200FootList"
End Property
Private Property Get ICommand_Tooltip() As String
   ICommand_Tooltip = "Create a 200' list"
End Property

Private Sub ICommand_OnCreate(ByVal hook As Object)
   Dim a As New UID
   Set m_pApp = hook
   a.Value = "CmdToolbarExt.clsLaunchExtension"
   Set m_pExt = m_pApp.FindExtensionByName("200FootListExtension")
End Sub

Private Sub ICommand_OnClick()             ''MAIN BUTTON
   Dim a As Long              'Field (i.e. column) value
   Dim b As Long             'b-d: counters
   Dim c As Long
   Dim d As Long
   Dim lMaxSize(8) As Long             'Width of each field
   Dim sValue As String             'Current record's value (string)
   Dim lHolder As Long             'Temp. field width value
   Dim sFieldName(8) As String
   Dim sBlock As String
   Dim sLot As String
   Dim sFirstRecord As String              'Holds IDNum of 1st selected record
   Dim sFileName As String
   sFieldName(0) = "IDNum"
   sFieldName(1) = "Block"
   sFieldName(2) = "Lot"
   sFieldName(3) = "FULLNAME"
   sFieldName(4) = "ADDRESS"
   sFieldName(5) = "CITY"
   sFieldName(6) = "STATE"
   sFieldName(7) = "ZIP"
   sFieldName(8) = "PROPLOC"
   Set m_pMxDoc = m_pApp.Document
   Set m_pMap = m_pMxDoc.FocusMap
   Set m_pFeatureLayer = m_pMxDoc.FocusMap.Layer(0)         '!!Change to reflect name
   Set m_pFeatureSelection = m_pFeatureLayer         ' of parcel layer!!
   Set m_pCursor = m_pFeatureLayer.Search(Nothing, False)
                                                                            'Create Excel file name
   Call m_pFeatureSelection.SelectionSet.Search(Nothing, False, m_pFeatureCursor)
   Set m_pFeature = m_pFeatureCursor.NextFeature
   sFirstRecord = "Block" & m_pFeature.Value(m_pFeature.Fields.FindField("Block")) & "Lot" & _
   Set m_pQBLayer = New QueryByLayer
   With m_pQBLayer             'Select all parcels within 200 feet
      Set .ByLayer = m_pFeatureLayer             ' of the selected parcel
      Set .FromLayer = m_pFeatureLayer
      .BufferDistance = 200
      .BufferUnits = esriFeet
      .ResultType = esriSelectionResultAdd
      .LayerSelectionMethod = esriLayerSelectWithinADistance
      .UseSelectedFeatures = True
      Set m_pFeatureSelection.SelectionSet = .Select
   End With

   Set m_pSelectionSet = m_pFeatureSelection.SelectionSet
   Call m_pSelectionSet.Search(Nothing, False, m_pCursor)

   Set m_pFields = m_pCursor.Fields
   Set m_pRow = m_pCursor.NextRow

'*******************************mostly ArcMap code above this line************
'*******************************mostly VBA code below this line***************
   Set m_pAppExcel = CreateObject("excel.application")         'Create Excel instance
   Set m_pWorkbook = m_pAppExcel.Workbooks.Add         'Create workbook/worksheet
   Set m_pWorksheet = m_pWorkbook.Sheets.Add(After:=m_pWorkbook.Sheets(m_pWorkbook.Sheets.Count))
   Cells(1, 1).Value = "IDNumber"             'Field names
   Cells(1, 2).Value = "Block"
   Cells(1, 3).Value = "Lot"
   Cells(1, 4).Value = "Name"
   Cells(1, 5).Value = "Address"
   Cells(1, 6).Value = "City"
   Cells(1, 7).Value = "State"
   Cells(1, 8).Value = "ZIP"
   Cells(1, 9).Value = "Property Loc."
   m_pAppExcel.DisplayAlerts = False             'Kill first three sheets
   m_pAppExcel.DisplayAlerts = True
   m_pWorksheet.Name = "200 Foot List"
   m_pWorksheet.Rows(1).Font.Bold = True
   c = 1
   d = 1
   Do While Not m_pRow Is Nothing             'Grab values from selection set
      c = c + 1
      For b = 0 To 8
         a = m_pFields.FindField(sFieldName(b))
         m_pWorksheet.Cells(c, d).Value = m_pRow.Value(a)         'Write value to record
         sValue = m_pRow.Value(a)
         If c = 2 Then             'Find the longest entry in each field
            lMaxSize(b) = Len(sValue)
            lHolder = Len(sValue)
            If lHolder > lMaxSize(b) Then
               lMaxSize(b) = lHolder
            End If
         End If
         d = d + 1
      Next b
      Set m_pRow = m_pCursor.NextRow
      d = 1
   If lMaxSize(0) < 10 Then lMaxSize(0) = 10         'Minimum widths for fields
   If lMaxSize(1) < 6 Then lMaxSize(1) = 6
   If lMaxSize(2) < 4 Then lMaxSize(2) = 4
   If lMaxSize(3) < 6 Then lMaxSize(3) = 6
   If lMaxSize(4) < 8 Then lMaxSize(4) = 8
   If lMaxSize(5) < 4 Then lMaxSize(5) = 4
   If lMaxSize(7) < 6 Then lMaxSize(7) = 6
   If lMaxSize(8) < 13 Then lMaxSize(8) = 13
   m_pWorksheet.Columns("A").ColumnWidth = lMaxSize(0)         'Set field widths
   m_pWorksheet.Columns("B").ColumnWidth = lMaxSize(1)
   m_pWorksheet.Columns("C").ColumnWidth = lMaxSize(2)
   m_pWorksheet.Columns("D").ColumnWidth = lMaxSize(3)
   m_pWorksheet.Columns("E").ColumnWidth = lMaxSize(4)
   m_pWorksheet.Columns("F").ColumnWidth = lMaxSize(5)
   m_pWorksheet.Columns("G").ColumnWidth = lMaxSize(6)
   m_pWorksheet.Columns("H").ColumnWidth = lMaxSize(7)
   m_pWorksheet.Columns("I").ColumnWidth = lMaxSize(8)
   sFileName = "C:200FootList_" & sFirstRecord & ".xls"
   Call m_pWorksheet.SaveAs(sFileName)         'Save Excel file (for this instance)
   m_pAppExcel.DisplayAlerts = False
   Call m_pWorksheet.SaveAs("C:200FootListMerger.xls")         'Save dummy copy of Excel file
   m_pAppExcel.DisplayAlerts = True             ' for mail merge (always overwrites)
   Call m_pWorkbook.Close
   Call m_pAppExcel.Application.Quit             'Quit Excel
   Set m_pAppWord = CreateObject("word.application")         'Create Word instance
   m_pAppWord.ActivePrinter = "\DellserverSHARP407 on Ne04:"

                                                                            'Open document for mail merge
   Set m_pDocument = m_pAppWord.Documents.Open("C:MailMerge.doc")

   Call m_pDocument.MailMerge.OpenDataSource("C:200FootListMerger.xls")
   m_pDocument.MailMerge.Destination = wdSendToNewDocument

   Call m_pDocument.PrintOut             'Print letters
   Call m_pDocument.Close
   Call m_pAppWord.Application.Quit(False)             'Quit Word
End Sub

Append Post-script Print Jobs?
I have a macro running that opens some workbooks, selects some sheets, and sends out a print job to Adobe PDF, and makes a post-script file. I would like to append all the print jobs into a single post script file. Is this possible? How could that work?

Also, the macro is being rewritten so that it opens word documents and sends them to the PDFer as well. Could I also have those appended into the same post script as the workbooks?


Monitoring Print Jobs From A Client In A Net Work
tried it a thousand & one times crushing my network always .
How do i ensure that i know which machine sent the print job. The code should be in visual basic 6.0 compatible.Right now i'm actually very mad

Combine Different Print Jobs As One For Printing Crystal Reports
I am working on an application which generates different reports and send them to printer directly. Also, in between I send page separator as an indicator of finishing certain part. Basically it is a collating program for different reports. My problem is, there are so many small print jobs which makes the printing very slow. I want to do something so that there is only one big print job to make it faster.

Here is the code I am using.
Public crpAPP As New CRPEAuto.Application
Public crpReport As New CRPEAuto.Report
Set crpAPP = CreateObject("Crystal.CRPE.Application")
Set crpReport = crpAPP.OpenReport(sReport)

Do Until SchoolRS.EOF
    Printer.CurrentY = mlngTopMargin + 4000
    Printer.Print " Start of Reports for School: "
    Printer.Print " "
    Printer.Print " " & SchoolRS!school_name
    Printer.Print " (" & SchoolRS!cds & ")"

   crpReport.SelectPrinter "winspool", Printer.DeviceName, Printer.Port
   crpReport.PrintOut False, 1

There are several reports being printed as separate print jobs each time the crpreport.Printout method executes. Also, the printer.EndDoc also does same thing.
Can somebody suggest a way to make them as a single print job?
Any suggestion in this direction will be great help.

Thanks in advance,

Know When Print Job Is Finished
From a CICS application i send a txt file in dir c:my_dir est.txt
my probem is when the job is finished...
How to be sure when the file is updatable or movable from dir to other dir???

from another application i send on a file, a job of print in this path:


after the job is finished i would want to start this my macro

sub import_file()

my problem is:

i dont know if the job of print is finshed...
i dont know the time of the print job in exact misure (is variable)
i dont know the fixed dimension of print job (is variable)

i would want a piece of code, and after this condition is established invoche a call to start my macro..

How To Know When The Print Job Is Finished? (Unresolved)
from another application i send on a txt file, a job of print in this path:


after the job is finished i would want to start this macro

sub import_file() --- (importing a data from this file in to sheet of a wbook)---

my problem is:

i dont know if the job of print is finshed...
i dont know the time of the print job in exact misure (is variable)
i dont know the fixed dimension of print job (is variable)

i would want a piece of code and after this have established the end of job prunt invoche a call to start my macro...


Edited by - sal21 on 6/21/2004 1:16:46 PM

How To Print A Ms Word,excel, Using VB?
I want to ask how to print any documents(word,excel etc etc) using VB. please help me. i need it in my research work. thanks in advance..^_^

What Is The Best Way/format To Print From You Finished Project.
Obviously there is information in my final project. I wish to print some of this information in a orderly fashion.

I will be pulling recordsets from the db , joining tables, etc. pulling information unique to each user.

The question is what is the best format to use when I want to print?

What controls do I use ? Label? Textbox?

An example of a report I want to print (information pulled from the db) would be similar to this:

Member Age Widgets
John Smith 52 15
Peter Paul 23 23
Jane Izo 55 81

If that makes sense someone please point me in the right direction. Help is needed.

Thanks in advance

Print Envelopes In Word From Excel
I have a list of names and addresses and I need to be able to loop through them one at a time, printing an envelope from Word for each one. Here's what I have right now but it's not working.

Sub envelopes()
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")

Dim lstnm As String
Dim fstnm As String
Dim add As String
Dim city As String
Dim state As String
Dim zip As String

Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.add

ActiveDocument.MailMerge.MainDocumentType = wdEnvelopes

ActiveDocument.MailMerge.OpenDataSource Name:= _
ichardqueenDatabasesJCMS Clients.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB .4.0;Password="""";User ID=Admin;Data Source=" _
& "\SBSNEALUsers
ichardqueenDatabasesJCMS Clients.xls;" _
& "Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";" _
& "Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";" _
& "Jet OLEDB:Database Passw" , _
SQLStatement:="SELECT * FROM `Letters$`", _
SQLStatement1:="", SubType:= wdMergeSubTypeAccess


fstnm = Selection.Offset(0, 1).Value
lstnm = Selection.Value
add = Selection.Offset(0, 2).Value
city = Selection.Offset(0, 3).Value
state = Selection.Offset(0, 4).Value
zip = Selection.Offset(0, 5).Value

ActiveDocument.Envelope.PrintOut ExtractAddress:=False, OmitReturnAddress _
:=True, PrintBarCode:=True, PrintFIMA:=False, Height:=InchesToPoints( _
4.13), Width:=InchesToPoints(9.5), Address:=fstnm & " " & lstnm & Chr(13) & _
add & Chr(13) & city & "," & state & " " & zip, AutoText:="", _
ReturnAddress:="", ReturnAutoText:="", AddressFromLeft:=wdAutoPosition, _
AddressFromTop:=wdAutoPosition, ReturnAddressFromLeft:=wdAutoPosition, _
ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:= _
wdCenterLandscape, DefaultFaceUp:=True, PrintEPostage:=False

Selection.Offset(1, 0).Activate

'Loop Until Selection.Value = "end"

With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
WordDoc.Close SaveChanges:=False
WordApp.Visible = True
Set WordDoc = Nothing
Set WordApp = Nothing

End Sub

Print Finished Exe/spool Stays Active
After printing forms with a VB app, you can exit the app but when you check the task manager, the exe is still active. Spool stays active.

Is there any command which can kill this when the printing is finished.

Monitoring A Folder Until Print Spooling Has Finished
I've been trying to monitor a folder during the creation of Windows print spool files, without success.
The reason being, is that during spooling, the files are created with a .$$$ file extension, and once each file is complete it's changed to .spl extension.
Before the next file is created (in a second or two) my loop thinks spooling is finished.
How can I ensure spooling is complete before importing all of the files?

I've been using a Do While loop. Is there another/better way?


How To Print An Embeded Word Document In Excel?

I have an excel file, and in one sheet I have embeded a word document. the word document is 12 pages long... how can I print the hole embeded word document??
I tried adding a print button in the word document and I only wrote


it gives me this error: This command is Invalid

I tried the same code in a normal word document and works just fine... but I do't know what happens when you insert the word document in an excel sheet...


How To Wait Till File Is Available/print Spooler/driver Is Finished
[vb6, MS Access]
I have a program that finishes by printing out a data report from a database, then deleting the database.

Prob is the execution is let continue after the
"DataReport1.PrintReport True"
As the program has finished sending the report the spooler service (I theorise ) so I trys to do the next instruction
"Fsys.DeleteFile Myfile, True"
but the spooling service/ printer is still reading it and holding it open.

no problem I thought, time for my first ever, "On Error" and just loop back to the delete instruction till it executes then finish.
BUT when I run the prog the error still showed first time it tried the instruction, instead of going to the On Error.....

So basically I need to be able to find out when my report has actually physically finished printing. is this possible?

Want To Write An Excel Macro That Automaticaly Closes Excel When Finished.
HELP!!! I am trying to get excel to close itself down after a macro has run but have no idea how to do it. I can get it to save&close the current spreadsheet but thats it. Can anybody please help?

Make Word Document Active And Print From Excel Macro
I have an excel spreadsheet with multiple hyperlinks to MS Word files. I know how to open the files using the following code:


ActiveWindow.View = xlNormalView
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

I need to know how to make the Word file the active window and then print it to the default printer in VB. I also need to know how to handle any error or warning messages. ie., when a box pops up to tell me the file should be opened as read only.


How To Print Word/Excel File Direct To Printer Without Opening That Fi
Is anyone know how to send a word document or a excel file direct to printer without open the file? Is there any command to do this?

Is just like from the windows explorer we point the mouse pointer to that file and right click and select the print to send to the printer.

I need this command to built in my application so that the userscan select a word document or a excel file by specify the filename and file path and then press a button to directly send to the printer.


How To Know If WORD Already Finished Loading The Document

Is there a way wherein i can know if word already finished loading the document in VB6?

I am having a problem in getting the number of pages in a WORD document because it does not get the exact number of pages sometimes..As of now i am using a delay after and before getting the builtinproperties.

I have the code below:

Set wordDocument = wordApp.Documents.Open(filePath)

delay here

Set documentProperties = Nothing
Set documentProperties = wordDocument.BuiltInDocumentProperties

documentContent = wordDocument.Content
documentNumPages = documentProperties.Item("Number of Pages").Value


Word - How To Tell If Printing Finished Before Quitting App
I'm sure this is dead simple but....

Someone has a Word macro that prints a document then it's supposed to exit. eg,


However, it quits before the printing is done and pops up a message. I'd have thought there would be a simple way to do something like

Do while ActiveDocument.IsPrinting = True

but I can't find the syntax.

Thanks in advance


How Can I Detect When A Word Document Has Finished Loading?

Is it possible to detect in the when a Word document has finished loading?

AutoOpen() and AutoExec() detect when a document is being opened or executed, but is there a way to detect when it has finished being loaded?

Any help much appreciated


Detect When Word&#039;s .PrintOut Command Has Finished
I am using the MS Word object library, and I am printing out large mail-merge documents via the .PrintOut command. I then need to close the document printed, but the problem is, if I issue a .Close command to the document, the print also terminates. Is there a way of detecting when a .PrintOut command has finished so that I can do a .Close on the document.

Shell And Continue Only When Db Is Finished Loading(program Finished)
I am starting another program with shell, and the program is loading a db and I do not want to use
sendkeys until I am sure the whole db has been loaded. The program only displays shortly in the main window that the db is opened and then some other info is displayed there. Even though I have the handle to the window it would not matter, because the window handle is the same for the two texts and the window title is also the same.

Does anybody have a good idea of how to solve this?

I guess I could try to check if the db folder has been opened, but that would not automatically mean that the program has finished loading. Is there not a way to check if a process has finished or not, when it is NOT your own program?

I have seen an example of a 'shell and wait' function, but here you have to eiter close the other app youself somehow and your own program get a return value. But I am looking for a way to automatically find when the program has finished, and then return to my own program.

Can any experts give me some help with how to solve this Please ? ?

When Has Excel Finished Printing?
I want to know in a macro when Excel has finished sending information to the printer. I believe that Word VBA will recognise
"Application.BackgroundPrintingStatus" but Excel VBA does not seem to. Any bright ideas please?

Copyright © 2005-08, All rights reserved