View Single Post
  #1  
Old 02-08-2012, 07:59 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
File Open Dialog

Hi,

I have a lot of scripts which prompts the user to open a file. At some point, these have stopped working and return an error. I've gotten a new PC with Windows 7 instead of XP and also upgraded to the latest version of SecureCRT (6.7.4) since the last time I've run these scripts. I don't know if it is something I'm missing, something that has changed, or something that is no longer supported.

The error I'm getting is:

Microsoft VBScript runtime error
Error: ActiveX component can't create object:
'UserAccounts.CommonDialog'

Obviously this is something outside of SecureCRT, but I don't know what would be the best or recommended method to fix this.

The code I've used for these scripts is:

Code:
	' -------- Open the file dialog --------
	Set fso = CreateObject("Scripting.FileSystemObject") 
	Set objDialog = CreateObject("UserAccounts.CommonDialog")
	objDialog.Filter = "Text Files|*.txt|VBScript Scripts|*.vbs|Log Files|*.log|All Files|*.*"
	objDialog.FilterIndex = 1
	Result = objDialog.ShowOpen
 	If Result = 0 Then
		ErrorStr = 3
		exit sub
	End If
	Set f = fso.GetFile(objDialog.FileName)
	Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
Thanks,

Wes
Reply With Quote