Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 02-08-2012, 07:59 AM
WesR WesR is offline
Registered User
Join Date: Mar 2005
Location: USA
Posts: 149
File Open Dialog


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:

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:

	' -------- 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)

Reply With Quote
Old 02-08-2012, 08:42 AM
bgagnon bgagnon is offline
VanDyke Technical Support
Join Date: Oct 2008
Posts: 4,636
Hi Wes,

That's correct, I believe ActiveX objects are system dependent, so objects that worked on XP may not work on Vista or Windows 7.

As an alternative, you can use the FileOpenDialog() method that was added to SecureCRT in version 6.7.

Changes in SecureCRT 6.7 (Beta 1) -- March 8, 2011

New features:
  • Added the script function FileOpenDialog() that displays the file browser and returns the selected file.

crt.Dialog.FileOpenDialog([title, [buttonLabel, [defaultFilename, [filter ]]]])

See the SecureCRT Help topic Scripting / Script Objects Reference / Dialog Object for additional information on the FileOpenDialog() method.

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote
Old 02-08-2012, 09:01 AM
WesR WesR is offline
Registered User
Join Date: Mar 2005
Location: USA
Posts: 149
Nice! Thanks. I missed that addition...

Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 11:10 PM.