Hi Archie,
A couple of things:
You need to pass object references in to the functions to get them to work reliably.
You might want to name your variables something other than the class names--just to avoid confusion.
Try something like this:
Rem N12 Script
Rem SCRIPT INFO
Rem -----------
Rem Copyright Mindware Corporation Of America
Rem Author: Archie O Tucker
Rem Created: 03/03/08
Rem Revised:
Dim myInDesign
Set myInDesign = CreateObject("InDesign.Application.CS3")
Set myDialog = myInDesign.Dialogs.Add
Set FileSys = CreateObject("Scripting.FileSystemObject")
Rem SET VALUES
Rem ----------
MountLetter = "N"
MountSize = "12"
TextFolder = "E:\sxs\pm65\CA\"
TemplateFolder = "E:\SXS\ID\"
BatchFolder = "E:\SXS\ID\"
Rem OPEN TEMPLATE
Rem -------------
Set myDocument = myInDesign.Open(TemplateFolder+MountLetter+MountSize+".indt", True)
Rem DISPLAY DIALOG
Rem --------------
myDialog.Name = MountLetter + MountSize + " Autobatch "
Set myDialogColumn = myDialog.DialogColumns.Add
Set myBorderPanel = myDialogColumn.BorderPanels.Add
Set mySubDialogColumn = myBorderPanel.DialogColumns.Add
Set myBatchNumberLabel = mySubDialogColumn.StaticTexts.Add
myBatchNumberLabel.StaticLabel = "Batch Number: "
Set mySubDialogColumn = myBorderPanel.DialogColumns.Add
Set myBatchNumberField = mySubDialogColumn.TextEditboxes.Add
myBatchNumberField.EditContents = "65926C"
myBatchNumberField.MinWidth = 100
Rem LINE:41
myResult = myDialog.Show
If myResult = True Then
myBatchNumber = myBatchNumberField.EditContents
myDefineColor myDocument
myPlaceText myDocument, myTextFolder, myMountSize, myBatchNumber
mySaveBatch myInDesign, myBatchFolder, myBatchNumber
myCloseTemplate myInDesign
myDialog.Destroy
Else
myDialog.Destroy
myCloseTemplate myInDesign
End If
Rem PLACE TEXT FUNCTION
Rem -------------------
Function myPlaceText(myDocument, myTextFolder, myMountSize, myBatchNumber)
Set myTextFrames = myDocument.TextFrames
Set myFirstFrame = myTextFrames.Item(1)
myFirstFrame.Place (TextFolder + MountSize + "_" + BatchNumber + ".TXT")
MsgBox "Ok:"
End Function
Rem SAVE BATCH FUNCTION
Rem -------------------
Function mySaveBatch(myInDesign, myBatchFolder, myBatchNumber)
myInDesign.ActiveDocument.Save BatchFolder + BatchNumber + ".indd"
End Function
Rem CLOSE TEMPLATE FUNCTION
Rem -----------------------
Function myCloseTemplate(myInDesign)
myInDesign.ActiveDocument.Close
End Function
Rem DEFINE COLORS
Rem ------------
Function myDefineColors(myDocument)
myDefineColor myDocument, "Green", idColorModel.idSpot, Array(100, 0, 100, 0)
myDefineColor myDocument, "Purple", idColorModel.idSpot, Array(60, 100, 0, 0)
myDefineColor myDocument, "Orange", idColorModel.idSpot, Array(0, 50, 100, 0)
myDefineColor myDocument, "Red", idColorModel.idSpot, Array(0, 100, 100, 0)
myDefineColor myDocument, "Blue", idColorModel.idSpot, Array(100, 100, 0, 0)
myDefineColor myDocument, "LBlue", idColorModel.idSpot, Array(76, 9, 0, 0)
myDefineColor myDocument, "LGreen", idColorModel.idSpot, Array(60, 0, 79, 0)
myDefineColor myDocument, "Brown", idColorModel.idSpot, Array(68, 70, 88, 0)
End Function
Rem DEFINE COLOR
Rem ------------
Function myDefineColor(myDocument, myColorName, myColorModel, myColorValue)
On Error Resume Next
Set myColor = myDocument.Colors.Item(myColorName)
If Error.Number > 0 Then
Set myColor = myDocument.Colors.Add
myColor.Name = myColorName
Error.Clear
End If
On Error GoTo 0
myColor.Model = myColorModel
myColor.ColorValue = myColorValue
End Function
Thanks,
Ole