Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 02-08-2012, 08:42 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,634
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.

Syntax:
Code:
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
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...

Wes
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 12:12 PM.