Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

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

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
TheHappyTech
Asked:
TheHappyTech
  • 6
  • 3
1 Solution
 
TheHappyTechAuthor Commented:



'--------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
 
TheHappyTechAuthor Commented:

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
 
Kyle AbrahamsSenior .Net DeveloperCommented:
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
TheHappyTechAuthor Commented:
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
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
TheHappyTechAuthor Commented:
Perfect Ged! I will try this out today and let you know the results.

Ben
0
 
TheHappyTechAuthor Commented:
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
 
TheHappyTechAuthor Commented:
Not fixed yet... not printing.
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
I'm assuming you found it with this?

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now