Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting run-time error on a vbscript used in a dts package 1

Status
Not open for further replies.

kskinne

Technical User
Oct 8, 2004
169
0
0
US
I have the following vbscript, running as an activex script inside a DTS package:

Function Main()
Set OpenFileDialog = CreateObject("MSComDlg.CommonDialog")
With OpenFileDialog
.DialogTitle = "Select Data Source"
.Filter = "All Files|*.*"
.FilterIndex = 4
.MaxFileSize = 1024
.InitDir = "S:\NBC\GC\CDRs\"
.ShowOpen
End With
MyStr = OpenFileDialog.FileName
MyChrPos = InStrRev(MyStr, "\")
MyStrLen = Len(MyStr)
MyFileName = Mid(MyStr, (MyChrPos + 1), (MyStrLen - MyChrPos))
If Left(MyFileName, 4) = "ETRF" Then
MyCarrierName = "Global Crossing"
ElseIf Left(MyFileName, 19) = "GC Switched Inbound" Then
MyCarrierName = "Global Crossing"
Else
MyCarrierName = InputBox("Enter Name of Carrier:", "Carrier Name" )
End If
MyEMRFileName = InputBox("Enter EMR filename:", "EMR File For Billing" )
DTSGlobalVariables("gVarData_Source").Value = MyStr
DTSGlobalVariables("gVarImport_File").Value = MyFileName
DTSGlobalVariables("gVarEMR_File").Value = MyEMRFileName
DTSGlobalVariables("gVarCarrier_Name").Value = MyCarrierName
Main = DTSTaskExecResult_Success
End Function

This runs fine on my workstation, but will not run on a different workstation in our office. Doesn't matter if I am logged in or someone else is. I installed script debugger, and it is erroring out on the first line of code. It is not telling me specifically what the error is though. It seems to me that for some reason on that machine it cannot handle the code for opening the file open dialog box.

Also if I put in the line On Error Resume Next at the top of the code, then it skips the first part of the code and then continues on correctly with the inputbox prompts. So It seems to me that for some reason on that machine it cannot handle the code for opening the file open dialog box.

Is there any setting or settings I can change on this other computer so that it can correctly run this part of the code?

Thank you for your help,
Kevin
 
Suspect that its the MSComDlg.CommonDialog that's causing the problem, as far as I know it's not part of the windows OS (I could be wrong) so it's not always available.

You could try this instead

Code:
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "All Files|*.*"
objDialog.InitialDir = "S:\NBC\GC\CDRs\"
intResult = objDialog.ShowOpen
If intResult = 0 Then
    Wscript.Quit
Else
    MyStr = objDialog.FileName
End If
 
I'll give that a try - by the way if I download the comdlg32.ocx file which from what I could find is the activex control for this, and save that to the machine's Windows\System\ folder, will that allow this to work?

Thanks,
Kevin
 
That new code works on either machine - thanks for the help

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top