Windows Scripting
  Home arrow Windows Scripting arrow Workarounds for Common Dialogs in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Workarounds for Common Dialogs in WSH
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-04-25

    Table of Contents:
  • Workarounds for Common Dialogs in WSH
  • Useful alternatives
  • The Browse For Folder dialog
  • Using the Browse For Folder dialog

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Workarounds for Common Dialogs in WSH


    (Page 1 of 4 )

    In my last article we learned how to use Microsoft’s Common Dialogs control to launch the File Open and File Save dialog boxes for grabbing user input. We also learned that this will not work in many cases. In this article we explore some alternative methods.

    If you missed the first part of this series, you should stop now and read it here.

    The first workaround for the Common Dialog control’s Open dialog is a very simple one.  It’s provided by the User Account control and works nearly identically to the original Common Dialog.

    Const WORD_DOCS = "Word Documents (*.doc)|*.doc|"

    Const ALL_FILES = "All Files (*.*)|*.*|"

    Set objDialog = CreateObject("UserAccounts.CommonDialog")

    objDialog.Filter = WORD_DOCS & ALL_FILES

    objDialog.FilterIndex = 1

    objDialog.InitialDir = "%homepath%\My Documents"

    intResult = objDialog.ShowOpen

    If intResult Then

       Wscript.Echo objDialog.FileName

    Else

       Wscript.Echo ""

    End If

    As you can see, this works in very much the same way.  The Filter and FilterIndex properties are used to set the default file types for the control and the ShowOpen method is used to launch it.

    Just as with Common Dialogs each file type filter requires two parts: the text description and the filter.  Parts are combined into a single piped string.

    Pipe is another name for the (|) character.  That’s the 124th ASCII character: that’s 124 in decimal notation, 0x7C in hex, and 0174 in octal.

    The two things to note when using this method are the use of the InitialDir property to specify the directory that the dialog should open to and the use of an If statement for parsing its return value.  If the user clicks the Cancel button, the dialog returns Nothing.

    Okay, so what else can we do to work around not being able to use Microsoft’s Common Dialogs control?

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · In the second part of this series I show you some common workarounds for using...
       · This workaround for the common dialogs was very useful, thanks a lot.Don't you...
       · Thanks for reading the article, I'm glad you enjoyed. To answer your question, I...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT