Solved

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

Posted on 2010-09-08
9
298 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 39

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 39

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 39

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

21 Experts available now in Live!

Get 1:1 Help Now