I am in the process of writing a script which must open a file. I am trying to use the GetOpenFileName procedure from Comdlg32.dll to select the file to open with no success. Has anyone tried this before? I have attached my script which runs properly with the VB script editor in Word but not the script editor in PCDMIS.
Basic Script and Common Dialog Procedures
Collapse
X
-
alternative method
I don't believe BASIC scripting allows you to work with the same common dialog as VB and VBA. It does have similar capabilities though, as shown in this example from the help file (found in the section titled - "Dialog Dialog Function"
Sub Main ()
Dim MyList$(2)
MyList(0) = "Banana"
MyList(1) = "Orange"
MyList(2) = "Apple"
Begin Dialog DialogName1 60, 60, 240, 184, "Test Dialog"
Text 10, 10, 28, 12, "Name:"
TextBox 40, 10,50, 12, .joe
ListBox 102, 10, 108, 16, MyList$(), .MyList1
ComboBox 42, 30, 108, 42, MyList$(), .Combo1
DropListBox 42, 76, 108, 36, MyList$(), .DropList1$
OptionGroup .grp1
OptionButton 42, 100, 48, 12, "Option&1"
OptionButton 42, 110, 48, 12, "Option&2"
OptionGroup .grp2
OptionButton 42, 136, 48, 12, "Option&3"
OptionButton 42, 146, 48, 12, "Option&4"
GroupBox 132, 125, 70, 36, "Group"
CheckBox 142, 100, 48, 12, "Check&A", .Check1
CheckBox 142, 110, 48, 12, "Check&B", .Check2
CheckBox 142, 136, 48, 12, "Check&C", .Check3
CheckBox 142, 146, 48, 12, "Check&D", .Check4
CancelButton 42, 168, 40, 12
OKButton 90, 168, 40, 12
PushButton 140, 168, 40, 12, "&Push Me 1"
PushButton 190, 168, 40, 12, "Push &Me 2"
End Dialog
Dim Dlg1 As DialogName1
Dlg1.joe = "Def String"
Dlg1.MyList1 = 1
Dlg1.Combo1 = "Kiwi"
Dlg1.DropList1 = 2
Dlg1.grp2 = 1
' Dialog returns -1 for OK, 0 for Cancel, button # for PushButtons
button = Dialog( Dlg1 )
'MsgBox "button: " & button 'uncomment for button return vale
If button = 0 Then Return
MsgBox "TextBox: "& Dlg1.joe
MsgBox "ListBox: " & Dlg1.MyList1
MsgBox Dlg1.Combo1
MsgBox Dlg1.DropList1
MsgBox "grp1: " & Dlg1.grp1
MsgBox "grp2: " & Dlg1.grp2
Begin Dialog DialogName2 60, 60, 160, 60, "Test Dialog 2"
Text 10, 10, 28, 12, "Name:"
TextBox 42, 10, 108, 12, .fred
OkButton 42, 44, 40, 12
End Dialog
If button = 2 Then
Dim Dlg2 As DialogName2
Dialog Dlg2
MsgBox Dlg2.fred
ElseIf button = 1 Then
Dialog Dlg1
MsgBox Dlg1.Combo1
End If
End Sub
Obviously, this doesn't exactly match your request, but all it takes is a little coding
Related Topics
Collapse
-
We want to assign the selected text (not the index number) of a DropListBox to a variable (see attachment).
With a ComboBox it is simple (Variable_A...-
Channel: PC-DMIS for CMMs
04-20-2012, 02:40 PM -
-
Master dialog box script. Help Plzz,
We are running 4.1
Note: This account is shared by Dr. D, & Stoner. Stoner...-
Channel: PC-DMIS for CMMs
05-28-2010, 09:18 AM -
-
I have a version of this script hooked to a custom icon so with one-click I can run it and add comments quickly, or add canned (standadized) comments...
-
Channel: PC-DMIS Code Samples
03-26-2012, 03:14 PM -
-
by BKulpaI can edit basic scripts on my offline seat but when I try to execute them I get the error attached.The scripts work fine on other computers but not my...
-
Channel: PC-DMIS for CMMs
02-28-2010, 09:36 AM -
-
by T MillerI have run this script many times. Here is the problem. If I have more then one assignment in the program it passes to them all and that is not a good...
-
Channel: PC-DMIS Code Samples
11-04-2008, 11:33 AM -
Comment