Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


et objDialog = Createobject("Useraccounts.Commondialog") and BrowseForFolder

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,23589
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> et objDialog = Createobject("Useraccounts.Commondialog") and BrowseForFolder
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 et objDialog = Createobject("Useraccounts.Commondi... - 7/13/2005 3:00:58 PM   
  406_sg

 

Posts: 2
Score: 0
Joined: 7/12/2005
Status: offline
Hi,  The code below is readily available on the net and it only works for Windows XP.  Any chance any1 has a workaround to get it to work on Windows 2000 machine?



Dim path_and_file

Set objDialog = Createobject("Useraccounts.Commondialog")
objDialog.Filter = "All files|*.*"
objDialog.Filterindex = 1
'objDialog.dialogTitle = "Select a file"
   intResult = objDialog.Showopen
   IF(intResult = 0) THEN
     'Wscript.quit
     intReturn = f
   ELSE
     Wscript.echo objDialog.FileName    
    
   END IF


On the other hand BrowseForFolder works on Windows 2000 where it was claimed it does not.
Thank in advance.

The script I am trying to write is to enable users to choose certains files and then sending them to a remote machine for processing...
 
 
Post #: 1
 
 RE: et objDialog = Createobject("Useraccounts.Comm... - 7/14/2005 9:50:33 PM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
I'm not sure about the environment your script has to run in, but this:

<html>
 <head>
  <hta:application id = "filedialog"
  />
  <title>filedialog</title>
  <meta http-equiv = "content-script-type" content = "text/vbscript"/>
  <script language = "VBScript"
          type     = "text/vbscript"
  >
'<![CDATA[

''= calls FileOpenDialog and sets sleTOSEND.value
' ============================================================================
Sub doFileOpenDialog()
  Dim oCDlg
  Dim sTmp

  Set oCDlg = CreateObject( "MSComDlg.CommonDialog" )
  If oCDlg Is Nothing Then
     MsgBox "CreateObject( 'MSComDlg.CommonDialog' ) failed."
     Exit Sub
  End If

  oCDlg.MaxFileSize = 10000
' Setting other oCDlg.Properties
' oCDlg.Filter      = ...
' ...

  oCDlg.ShowOpen

  document.all.sleTOSEND.value = oCDlg.Filename  ' FSpec

End Sub

''= checks for FSpecs and calls (fake)Send
' ============================================================================
Sub doSend()
  Dim bNix
  Dim sFSpec

  bNix   = True

  sFSpec = document.all.filTOSEND.value
  If "" <> Trim( sFSpec ) Then
     fakeSend sFSpec
     bNix = False
  End If

  sFSpec = document.all.sleTOSEND.value
  If "" <> Trim( sFSpec ) Then
     fakeSend sFSpec
     bNix = False
  End If

  If bNix Then
     MsgBox "Please specify at least one file to send."
  End If
End Sub

''= fakes sending file sFSpec to a remote machine for processing
' ============================================================================
Sub fakeSend( sFSpec )
  MsgBox   "About to send: " + vbCrLf _
         + sFSpec            + vbCrLf _
         + "to a remote computer"
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================
Sub reloadHTA()
  location.reload( True )
End Sub

']]>
  </script>
 </head>
 <body>
  <input type = "FILE" id = "filTOSEND">
  <hr />
  <input type = "TEXT" id = "sleTOSEND">
  <input type = "BUTTON" onclick = "doFileOpenDialog()" value = "Choose file to send">
  <hr />
  <input type = "BUTTON" value = "send file to remote computer" onclick = "doSend()">
  <hr />
  <input type = "BUTTON" value = "reload" onclick = "reloadHTA()">
 </body>
</html>
 
runs on my W 2000 machine. For compatibility and amount-of-work reasons I would stick
with the INPUT/FILE approach.

(in reply to 406_sg)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> et objDialog = Createobject("Useraccounts.Commondialog") and BrowseForFolder Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts