Solved

VBS - need Order Number to be printed on bottom of page

Posted on 2010-09-08
9
301 Views
Last Modified: 2013-12-17
A previous IT guy had programmed this code to print pictures on a Microsoft Word document.

However, because of the volume of these documents.

We need either 1) best case scenario - the Order Number to be printed on the BOTTOM of the page. Or 2) the page number at the Bottom of the page (just to make them easier to sort out).

(I replaced the "servername" with "mycompany").

Thank you,
HappyTech
Option Explicit
On Error Resume Next

Dim objFSO
Dim FS
Dim TextStream
Dim Line
Dim FileName
Dim NewFileName
Dim FolderPath 
Dim objFolder
Dim colFiles
Dim objFile
Dim X
Dim NewName
Dim AppWord
Dim Doc1
Dim ordernum
Dim OrderFile

ordernum = Wscript.Arguments.Item(0)
OrderFile = "\\mycompany\shares\share1\TDR\Orders\" & Ordernum & ".txt"


Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.DeleteFile("\\mycompany\shares\share1\TDR\Converted\*.jpg")
objFSO.DeleteFile("\\mycompany\shares\share1\TDR\RAW\*.jpg")

Set FS = objFSO.GetFile("\\mycompany\shares\share1\TDR\Orders\" & Ordernum & ".txt")

set TextStream = FS.OpenAsTextStream()


Do While Not TextStream.AtEndOfStream
		
		Line = TextStream.readline
		Line = Trim(Line)

		Filename = "\\mycompany\shares\share1\TDR\TDR_Images\" & Line & ".jpg"
		NewFileName = "\\mycompany\shares\share1\TDR\RAW\" & Line & ".jpg"

	objFSO.copyfile Filename, NewFileName, True
		
		
	Loop



X=1
FolderPath = "\\mycompany\shares\share1\TDR\Raw"

Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files




For Each objFile In colFiles

NewName = "\\mycompany\shares\share1\TDR\Converted\" & x & ".jpg"
objFile.Copy NewName
x=x+1

Next

objFSO.DeleteFile("\\mycompany\shares\share1\TDR\RAW\*.jpg")

if x<11 then 

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
appword.visible=true

End if 

if x>10 and x<21 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
appword.visible=true

End if

if x>20 and x<31 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

appword.visible=true

End if

if x>30 and x<41 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
appword.visible=true

End if

if x>40 and x<51 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

appword.visible=true

End if

if x>50 and x<61 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
appword.visible=true

End if

if x>60 and x<71 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

appword.visible=true

End if

if x>70 and x<81 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

appword.visible=true

End if

if x>80 and x<91 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

appword.visible=true

End if

if x>90 and x<101 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
appword.visible=true

End if

if x>100 and x<111 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
appword.visible=true

End if

if x>110 and x<121 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
appword.visible=true

End if


if x>120 and x<131 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
appword.visible=true

End if


if x>130 and x<141 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")
appword.visible=true

End if


if x>140 and x<151 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")
appword.visible=true

End if


if x>150 and x<161 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")
appword.visible=true

End if


if x>160 and x<171 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label17.doc")
appword.visible=true

End if

if x>170 and x<181 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label17.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label18.doc")
appword.visible=true

End if

if x>180 and x<191 then

Set AppWord = CreateObject("Word.Application")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label17.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label18.doc")
AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label19.doc")
appword.visible=true

End if



If x>190 then 

msgbox("You are trying to print " & x & " TDRs" & vbCRLF & "Our current limit is 190.  Please call IT!")

End If

Open in new window

0
Comment
Question by:TheHappyTech
  • 6
  • 3
9 Comments
 

Author Comment

by:TheHappyTech
ID: 33630191



'--------Start Script----------
Dim ordernum
Dim loopnum
Dim txtfile
Dim filename
Dim custname

 ordernum = Wscript.Arguments.Item(0)

'ordernum = "0000000015"

loopnum = 0


strConnectionString = "Driver={SQL Server};Server=masserv;Database=mas500_app;Uid=administrator;Pwd=password;"
Set connection = CreateObject("ADODB.Connection") 
connection.Open strConnectionString 


Set RS = CreateObject("ADODB.Recordset")


strSQL = "SELECT tsoSalesOrder.TranNo AS OrderNumber, timItem.ItemID AS ItemNumber"
strSQL = strSQL & " FROM tsoSalesOrder INNER JOIN tsoSOLine ON tsoSalesOrder.SOKey = tsoSOLine.SOKey INNER JOIN"
strSQL = strSQL & " timItem ON tsoSOLine.ItemKey = timItem.ItemKey INNER JOIN timItemUDF_mis ON timItem.ItemKey ="
strSQL = strSQL & "timItemUDF_mis.ItemKey WHERE (timItemUDF_mis.TDRItem = 1) AND (tsoSalesOrder.TranNo = '" & ordernum & "')"


RS.Open strSQL, connection

msgbox "The TDR List has been created and" & vbCRLF & "an email will be sent to IT in a few minutes!" & vbCRLF & "Thanks for clicking!"

txtfile=""

do while not RS.EOF
txtfile = txtfile & rs("ItemNumber") & vbCRLF 
RS.movenext
loopnum=loopnum + 1
loop 

txtfile = txtfile & vbCRLF

RS.close 
connection.close 
Set RS = nothing 
Set connection = nothing


filename = "\\mycompany\shares\share1\TDR\Orders\" & ordernum & ".txt"


Set FS = CreateObject("Scripting.FileSystemObject")
Set FA = FS.CreateTextFile(filename, True)
FA.Write(txtfile)
FA.Close
set FA = nothing
set FS = nothing

Const cdoSendUsingMethod        = _
	"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             = _
	"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         = _
	"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  = _
	"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       = _
	"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           = _
	"http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           = _
	"http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields
Dim OrdNum

Dim txtBDY


' Get a handle on the config object and it's fields
Set objConfig = CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
	.Item(cdoSendUsingMethod)       = cdoSendUsingPort
	.Item(cdoSMTPServer)            = "mycompany"
	.Item(cdoSMTPServerPort)        = 25
	.Item(cdoSMTPConnectionTimeout) = 10
	.Item(cdoSMTPAuthenticate)      = cdoBasic
	.Item(cdoSendUserName)          = "administrator"
	.Item(cdoSendPassword)          = "password"
	.Update
End With
txtBDY = "<font face=arial size=3>We need to print cards for Order #<b>" & Ordernum & "</b><br><br>" 
txtBDY = txtBDY & "to automatically create word documents from the TDR items, paste the following into the 'run' box:<br><b>"
txtBDY = txtBDY & "\\mycompany\shares\Share1\TDR\setupTDR_xerox.vbs " & ordernum & "</b>"

Set objMessage = CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
	.To       = "IT <IT@mycompany.com>"
	.From     = "Order Entry TDR Squad <IT@mycompany.com>"
	.Subject  = "New TDR Card Request (MAS 500)"
	.HTMLBody = txtBDY
	.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing



































'------End Script--------

Open in new window

0
 

Author Comment

by:TheHappyTech
ID: 33630212

Folderspec="\mycompany\shares\share1\TDR\TDR_Images\"
filename="\\mycompany\shares\share1\TDRlist.txt"
Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.Files
    For Each f1 in fc
        s = s & f1.name 
        s = s & vbCrLf
    Next
    MsgBox s



Set FA = FS.CreateTextFile(filename, True)
FA.Write(s)
FA.Close
set FA = nothing
set FS = nothing

Open in new window

0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 33630224
0
 

Author Comment

by:TheHappyTech
ID: 33631232
Thank you Ged325!!! Alright, I havent done any programming in my life, so I will just ask you simply...
1) is that all I have to do is add that code to first script I posted?

2) That script you posted above shows the Date, how could I have the Order Number inputed/displayed?

3) I am ready to give you 500 points, I just need a bit more "help" until the code is done :)

HappyT
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 33636472
In the code you have:

ordernum = Wscript.Arguments.Item(0)

so I'm assuming this is your order number.

1)  Copy the code into your vbs script at the bottom
2)  

You have to modify your calls

from

AppWord.Documents.open("\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

to

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

(or whatever the appropriate label is)




sub Open_And_AddOrderNum(ordernum, path)



Const END_OF_STORY = 6

Const MOVE_SELECTION = 0





Set objWord = CreateObject("Word.Application")

objWord.Visible = True



Set objDoc = objWord.Documents.Open(path)

Set objSelection = objWord.Selection

objSelection.EndKey END_OF_STORY, MOVE_SELECTION



objSelection.TypeParagraph()

objSelection.TypeParagraph()



objSelection.Font.Size = "14"

objSelection.TypeText "" & ordernum

objSelection.TypeParagraph()

objSelection.TypeParagraph()

objSelection.Font.Size = "10"



end sub

Open in new window

0
 

Author Comment

by:TheHappyTech
ID: 33639052
Perfect Ged! I will try this out today and let you know the results.

Ben
0
 

Author Comment

by:TheHappyTech
ID: 33641265
Im getting an error:

Windows Script Host

Script     \\mycompany\shares\Share1\TDR\SetupTDR_Xerox1.vbs
Line        72
Char       84
Error       Cannot use parentheses when calling a Sub
Code      800A0414
Source   Microsoft VBScript compilation error

Anyone know how to fix?

HappyT
Option Explicit

On Error Resume Next



Dim objFSO

Dim FS

Dim TextStream

Dim Line

Dim FileName

Dim NewFileName

Dim FolderPath 

Dim objFolder

Dim colFiles

Dim objFile

Dim X

Dim NewName

Dim AppWord

Dim Doc1

Dim ordernum

Dim OrderFile



ordernum = Wscript.Arguments.Item(0)

OrderFile = "\\mycompany\shares\share1\TDR\Orders\" & Ordernum & ".txt"





Set objFSO = CreateObject("Scripting.FileSystemObject")



objFSO.DeleteFile("\\mycompany\shares\share1\TDR\Converted\*.jpg")

objFSO.DeleteFile("\\mycompany\shares\share1\TDR\RAW\*.jpg")



Set FS = objFSO.GetFile("\\mycompany\shares\share1\TDR\Orders\" & Ordernum & ".txt")



set TextStream = FS.OpenAsTextStream()





Do While Not TextStream.AtEndOfStream

		

		Line = TextStream.readline

		Line = Trim(Line)



		Filename = "\\mycompany\shares\share1\TDR\TDR_Images\" & Line & ".jpg"

		NewFileName = "\\mycompany\shares\share1\TDR\RAW\" & Line & ".jpg"



	objFSO.copyfile Filename, NewFileName, True

		

		

	Loop







X=1

FolderPath = "\\mycompany\shares\share1\TDR\Raw"



Set objFolder = objFSO.GetFolder(FolderPath)

Set colFiles = objFolder.Files









For Each objFile In colFiles



NewName = "\\mycompany\shares\share1\TDR\Converted\" & x & ".jpg"

objFile.Copy NewName

x=x+1



Next



objFSO.DeleteFile("\\mycompany\shares\share1\TDR\RAW\*.jpg")



if x<11 then 



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

appword.visible=true



End if 



if x>10 and x<21 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

appword.visible=true



End if



if x>20 and x<31 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")



appword.visible=true



End if



if x>30 and x<41 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

appword.visible=true



End if



if x>40 and x<51 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")



appword.visible=true



End if



if x>50 and x<61 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

appword.visible=true



End if



if x>60 and x<71 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")



appword.visible=true



End if



if x>70 and x<81 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")



appword.visible=true



End if



if x>80 and x<91 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")



appword.visible=true



End if



if x>90 and x<101 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

appword.visible=true



End if



if x>100 and x<111 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

appword.visible=true



End if



if x>110 and x<121 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

appword.visible=true



End if





if x>120 and x<131 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

appword.visible=true



End if





if x>130 and x<141 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")

appword.visible=true



End if





if x>140 and x<151 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")

appword.visible=true



End if





if x>150 and x<161 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")

appword.visible=true



End if





if x>160 and x<171 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label17.doc")

appword.visible=true



End if



if x>170 and x<181 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label17.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label18.doc")

appword.visible=true



End if



if x>180 and x<191 then



Set AppWord = CreateObject("Word.Application")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label2.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label3.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label4.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label5.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label6.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label7.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label8.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label9.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label10.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label11.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label12.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label13.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label14.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label15.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label16.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label17.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label18.doc")

Open_And_AddOrderNum(ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label19.doc")

appword.visible=true



End if







If x>190 then 



msgbox("You are trying to print " & x & " TDRs" & vbCRLF & "Our current limit is 190.  Please call IT!")



End If



sub Open_And_AddOrderNum(ordernum, path)



Const END_OF_STORY = 6

Const MOVE_SELECTION = 0





Set objWord = CreateObject("Word.Application")

objWord.Visible = True



Set objDoc = objWord.Documents.Open(path)

Set objSelection = objWord.Selection

objSelection.EndKey END_OF_STORY, MOVE_SELECTION



objSelection.TypeParagraph()

objSelection.TypeParagraph()



objSelection.Font.Size = "14"

objSelection.TypeText "" & ordernum

objSelection.TypeParagraph()

objSelection.TypeParagraph()

objSelection.Font.Size = "10"



end sub

Open in new window

0
 

Author Closing Comment

by:TheHappyTech
ID: 33647306
Not fixed yet... not printing.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 33648772
I'm assuming you found it with this?

Open_And_AddOrderNum ordernum,"\\mycompany\shares\share1\TDR\Docs_Xerox\Label1.doc"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now