I thought it my help others if I posted my "Global Script". I handle many templates and all of them have some things in common. So I devised what I call a Global Script. Most of the scripts below are used in each and every template I build. To me, this makes sense and is more efficient than attaching individual scripts to each field. I think it also eliminates many errors and typos.
There a quite a bit of script here. Use what you can.
'******Fields Included in Script************
'the fields listed below must be added to the script before entering the script in ABBYY
'SC_BatchName SC_Recognized SC_DocumentNumber (only read only field-SERVICE FIELD-) SC_ID
'Image_URL Image_URL_Prefix Image_URL_Suffix
'Date DateINT MM DD YY
'ImageFiles EditedBy Affiliate_Group_ID
'Possible - EmpSite
'******Fields Included in Script************
'Gets Batch Name
me.Field("SC_BatchName").Text = me.Document.BatchName
'SC_Recognized is entered
me.Field("SC_Recognized").Value = (Date) + (Time)
'If no date then enter Now
If (me.Field("MM").Text = "") THEN me.Field("MM").Text = Month(Date())
If (me.Field("DD").Text = "") THEN me.Field("DD").Text = Day(Date())
If (me.Field("YY").Text = "") THEN me.Field("YY").Text = Year(Date())
'Strip blank spaces
me.Field("MM").Text = Replace(me.Field("MM").Text," ","")
me.Field("DD").Text = Replace(me.Field("DD").Text," ","")
me.Field("YY").Text = Replace(me.Field("YY").Text," ","")
'Set [MM], [DD], [YY]
If Len(me.Field("MM").Text) = 1 then me.Field("MM").Text = "0" + me.Field("MM").Text
If Len(me.Field("DD").Text) = 1 then me.Field("DD").Text = "0" + me.Field("DD").Text
If Len(me.Field("YY").Text) = 2 then me.Field("YY").Text = "20" + me.Field("YY").Text
'Merge Date
me.Field("Date").Text = me.Field("MM").Text + "/" + me.Field("DD").Text + "/" + Me.Field("YY").Text
'DateINT
me.Field("DateINT").Text = me.Field("YY").Text + me.Field("MM").Text + me.Field("DD").Text
'After [MM] is verified, the SC_ID Merge will occur
if me.Field("MM").IsVerified then me.Field("SC_ID").Text = me.Field("SC_BatchName").Text + "_" + Me.Field("SC_Recognized").Text + "_" + Me.Field("SC_DocumentNumber").Text
'After the SC_ID Merge - Find and Replace
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text," ","_")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,".","-")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,":","-")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,"/","-")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,"Batch_HF_ID","B")
'Handles the Image_URL ***CompanyInCanada\20110105\***
'Where CompanyInCanada = The folder name designates the Project's Company Name
me.Field("Image_URL_Prefix").Text = "CompanyInCanada\20110105\"
me.Field("Image_URL_Suffix").Text = ".tif"
me.Field("Image_URL").Text = me.Field("Image_URL_Prefix").Text + Me.Field("SC_ID").Text + Me.Field("Image_URL_Suffix").Text
'Gets the original ImageFile name and strips our preceding folders
me.Field("ImageFiles").Text = me.Document.Pages.Item(0).ImageSource
Dim pos
pos = InStrRev(me.Field("ImageFiles").Text,"\")
me.Field("ImageFiles").Text = Mid(me.Field("ImageFiles").Text , pos + 1)
'Will look for various strings contained in the ImageFile name and place a code into a designated field
'Script is good for using the ImageFile name to determine the originating location and then placing ‘information into a certain field
'This will take a string from the original ImageFile and put a code into the field [EmpSite]
'All scan locations have their location in the ImageFile name, such as "20130610_Albian_(0001).tif
‘If InStr(LCase(me.Field("ImageFiles").Text), "albian") Then
‘ me.Field("EmpSite").Text = "1"
‘ElseIf InStr(LCase(me.Field("ImageFiles").Text), "in-situ") Then
‘ me.Field("EmpSite").Text = "2"
‘ElseIf InStr(LCase(me.Field("ImageFiles").Text), "scotford") Then
‘ me.Field("EmpSite").Text = "3"
‘Else
‘ me.Field("EmpSite").Text = "wc"
‘End If
‘This script works consistently for EditedBy
'It returns the User's login on the server. That way I know who verified the batch
Dim objNetworkDim
Set objNetwork = CreateObject("WScript.Network")
me.Field("EditedBy").Text = objNetwork.UserName
There a quite a bit of script here. Use what you can.
'******Fields Included in Script************
'the fields listed below must be added to the script before entering the script in ABBYY
'SC_BatchName SC_Recognized SC_DocumentNumber (only read only field-SERVICE FIELD-) SC_ID
'Image_URL Image_URL_Prefix Image_URL_Suffix
'Date DateINT MM DD YY
'ImageFiles EditedBy Affiliate_Group_ID
'Possible - EmpSite
'******Fields Included in Script************
'Gets Batch Name
me.Field("SC_BatchName").Text = me.Document.BatchName
'SC_Recognized is entered
me.Field("SC_Recognized").Value = (Date) + (Time)
'If no date then enter Now
If (me.Field("MM").Text = "") THEN me.Field("MM").Text = Month(Date())
If (me.Field("DD").Text = "") THEN me.Field("DD").Text = Day(Date())
If (me.Field("YY").Text = "") THEN me.Field("YY").Text = Year(Date())
'Strip blank spaces
me.Field("MM").Text = Replace(me.Field("MM").Text," ","")
me.Field("DD").Text = Replace(me.Field("DD").Text," ","")
me.Field("YY").Text = Replace(me.Field("YY").Text," ","")
'Set [MM], [DD], [YY]
If Len(me.Field("MM").Text) = 1 then me.Field("MM").Text = "0" + me.Field("MM").Text
If Len(me.Field("DD").Text) = 1 then me.Field("DD").Text = "0" + me.Field("DD").Text
If Len(me.Field("YY").Text) = 2 then me.Field("YY").Text = "20" + me.Field("YY").Text
'Merge Date
me.Field("Date").Text = me.Field("MM").Text + "/" + me.Field("DD").Text + "/" + Me.Field("YY").Text
'DateINT
me.Field("DateINT").Text = me.Field("YY").Text + me.Field("MM").Text + me.Field("DD").Text
'After [MM] is verified, the SC_ID Merge will occur
if me.Field("MM").IsVerified then me.Field("SC_ID").Text = me.Field("SC_BatchName").Text + "_" + Me.Field("SC_Recognized").Text + "_" + Me.Field("SC_DocumentNumber").Text
'After the SC_ID Merge - Find and Replace
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text," ","_")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,".","-")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,":","-")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,"/","-")
me.Field("SC_ID").Text = Replace(me.Field("SC_ID").Text,"Batch_HF_ID","B")
'Handles the Image_URL ***CompanyInCanada\20110105\***
'Where CompanyInCanada = The folder name designates the Project's Company Name
me.Field("Image_URL_Prefix").Text = "CompanyInCanada\20110105\"
me.Field("Image_URL_Suffix").Text = ".tif"
me.Field("Image_URL").Text = me.Field("Image_URL_Prefix").Text + Me.Field("SC_ID").Text + Me.Field("Image_URL_Suffix").Text
'Gets the original ImageFile name and strips our preceding folders
me.Field("ImageFiles").Text = me.Document.Pages.Item(0).ImageSource
Dim pos
pos = InStrRev(me.Field("ImageFiles").Text,"\")
me.Field("ImageFiles").Text = Mid(me.Field("ImageFiles").Text , pos + 1)
'Will look for various strings contained in the ImageFile name and place a code into a designated field
'Script is good for using the ImageFile name to determine the originating location and then placing ‘information into a certain field
'This will take a string from the original ImageFile and put a code into the field [EmpSite]
'All scan locations have their location in the ImageFile name, such as "20130610_Albian_(0001).tif
‘If InStr(LCase(me.Field("ImageFiles").Text), "albian") Then
‘ me.Field("EmpSite").Text = "1"
‘ElseIf InStr(LCase(me.Field("ImageFiles").Text), "in-situ") Then
‘ me.Field("EmpSite").Text = "2"
‘ElseIf InStr(LCase(me.Field("ImageFiles").Text), "scotford") Then
‘ me.Field("EmpSite").Text = "3"
‘Else
‘ me.Field("EmpSite").Text = "wc"
‘End If
‘This script works consistently for EditedBy
'It returns the User's login on the server. That way I know who verified the batch
Dim objNetworkDim
Set objNetwork = CreateObject("WScript.Network")
me.Field("EditedBy").Text = objNetwork.UserName