Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copies od Document

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
IE
We have an VB application which processes various data and produces Word Documents from templates. Within each template there is a macro which produces the original document and a copy. At present the original prints followed by the copy. There can be thousands of documents produced. There is now a need to print all the originals together followed by the copies i.e. thousands of originals and then thousands of copies. Is there any way to produce this without a complete re-design. I suspect the answer is no.

Regards,
 
Sorry, but you need to provide more detail.

Is this one macro copied across all the templates?
Are the documents produced batch wise?
When does the print routine fire?
Are you asking about changing existing documents, or new ones produced by this app?

More info please.

Gerry
My paintings and sculpture
 
We have an application which reads data from a batch file. Each document is identified in the batch file. The application reads the batch file and populates the document. there is a macro in each template which decides which documents get produced for Client and Agent. I refered to client and agent previously as original and copy. the client and the agent copies get produced one after the other. What I need to do is for each batch produce all client docs and then produce all agent docs. The only way I can think to do this is to change the macros and process the batch file twice. once for the client and once for the agent.
 
I suspect your use of the word "template" is incorrect. But maybe not. Let's assume I am wrong.

1. The application reads the batch file.
2. In the batch file is a list of documents. This seems odd to me, but whatever.
3. The application takes a name of a document, opens it, and puts stuff in it. This is what I interpret as "populates the document". If it is a document, then it is not a template. If it is a template, then the template makes a NEW document. Which is it?
4. The document (or template) produces...hmmmm...new documents????? Client, and Agent. Again this sounds odd.

In any case, a batch file is a batch file. It does things one after the other, after the other. I am very confused as to the process here. And i am unsure what is being done by the batch file, and what is being done by some macro in the "template"...which may in fact NOT be a template but a document.

Hmmmmm. Could you post some code?

Gerry
My paintings and sculpture
 
I guess my terminology is confusing.

By batch file I don't mean a .bat file. The batch file contains the data required to produce the documents including a DocumentID which determines which template will be used.

Each template has macros as follows:

Option Explicit

'General Variables
Dim lFileCount As Long
Dim sRequest As String
Private Const ORIGINAL As Integer = 1
Private Const COPY As Integer = 2
Public bAgentStatus As Boolean
Dim iNoOfDocCounter As Integer

Public Sub LoadTemplates(colDf As Collection)
On Error GoTo ErrorHandler

setCollection colData:=colDf

sRequest = Find_Field("PrintJob", "REQUESTID", 1)

bAgentStatus = GetAgentStatus()

LoadClientDocs

' Add Agent Copies
If bAgentStatus Then
LoadAgentDocs
End If

Finish:
Exit Sub
ErrorHandler:
ErrorRoutine ("SSIA_Maturity_Statement_Pack::LoadTemplates")
End Sub

Public Sub LoadClientDocs()
On Error GoTo ErrorHandler

lFileCount = 0

'Call & Build Client Statement (Covering Letter included)
BuildTemplate "SSIA_Maturity_Statement_Client_Covering_Letter.dot ", ORIGINAL, lFileCount, sRequest
BuildTemplate "SSIA_Maturity_Statement.dot ", ORIGINAL, lFileCount, sRequest

LoadSubDocuments sRequestID:=sRequest, lFiles:=lFileCount

Call RemoveBlankFirstPage

iNoOfDocCounter = iNoOfDocCounter + 1

CreateOMRDetails colDf:=objClass, iNoOfDocCounter:=iNoOfDocCounter, _
bFeederOne:=False, bDuplex:=False

Finish:
Exit Sub
ErrorHandler:
ErrorRoutine ("SSIA_Maturity_Statement_Pack::LoadClientDocs")
End Sub

Public Sub LoadAgentDocs()
On Error GoTo ErrorHandler

lFileCount = 0

BuildTemplate "SSIA_Maturity_Statement_Agent_Covering_Letter.dot", ORIGINAL, lFileCount, sRequest
BuildTemplate "SSIA_Maturity_Statement_Client_Covering_Letter.dot", COPY, lFileCount, sRequest
BuildTemplate "SSIA_Maturity_Statement.dot", COPY, lFileCount, sRequest

LoadSubDocuments sRequestID:=sRequest, lFiles:=lFileCount

iNoOfDocCounter = iNoOfDocCounter + 1

CreateOMRDetails colDf:=objClass, iNoOfDocCounter:=iNoOfDocCounter, _
bFeederOne:=False, bDuplex:=False

Finish:
Exit Sub
ErrorHandler:
ErrorRoutine ("SSIA_Maturity_Statement_Pack::LoadAgentDocs")
End Sub


In the vb application the templates are loaded as follows:

Private Sub Build_Document()
On Error GoTo ErrorHandler
Dim lErrCount As Long

' Add the template to the Existing Word object
objWordApp.Documents.Add Template:=g_objDocServerDetails.GetTemplateFileName
objWordApp.Documents(1).Activate
objWordApp.Documents(1).VBProject.VBComponents(1).Activate

' Add the Universal Template
objWordApp.AddIns.Add FileName:="GenTemp.dot", Install:=True
If IsAnnualStatement Or IsTransactionStatement Then
objWordApp.AddIns.Add FileName:="GeneralAnnTrans.dot", Install:=True
End If

If g_objDocServerDetails.GetEventFlag <> 9 Then
'Set these values here, as they are sometimes changed in templates
sOriginal = UCase(colDataFile.Item("PrintDetails;1").Item("Original"))
If Val(Find_Field("PrintDetails", "ClientCopies", 1)) > 0 Then
sCopy = "CLIENT"
ElseIf Val(Find_Field("PrintDetails", "AgentCopies", 1)) > 0 Then
sCopy = "AGENT"
End If
End If

objWordApp.ActiveDocument.LoadTemplates colDf:=colDataFile

Finish:
Exit Sub
ErrorHandler:
If Err.Number = ERR_WORDAUTOMATION Or Err.Number = ERR_WORDAUTOMATION2 _
Or Err.Number = ERR_AUTOMATION Then
Call gObjErrorHandler.WriteLog("Word automation warning in frmDocServer::Build_Document, " & _
"restarting the word process: Err.No-" & Err.Number & _
", Err.Desc-" & Err.Description)
Call KillWordProcesses
Call CreateWordObject
Resume
Else
Call ErrorRoutine("frmDocServer::Build_Document, the error is " & Err.Description)
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top