Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


using Windows CommonDialog

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> using Windows CommonDialog
  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 >>
 using Windows CommonDialog - 8/2/2005 2:45:15 AM   
  sambaram

 

Posts: 3
Score: 0
Joined: 8/2/2005
Status: offline
Looking at the script below from microsoft.com to open a file...well how can I echo JUST the FILENAME instead of the entire path?  eg. if objDialog.Filename = C:\Program Files\Test.txt  then I would just like to wscript.echo Test        (no file extension neither file path)
Someone please assist as I am stuck with writing a vbscript for Oracle db.
    Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Select Oracle Backup file|*.dat|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen

If intResult = 0 Then
    Wscript.Quit
Else
    Wscript.Echo objDialog.FileName
   End If


_____________________________

dasdasd
 
 
Post #: 1
 
 RE: using Windows CommonDialog - 8/2/2005 4:31:47 AM   
  sambaram

 

Posts: 3
Score: 0
Joined: 8/2/2005
Status: offline
I GOT IT!!


See modfied version of code below.

Set objDialog = CreateObject("UserAccounts.CommonDialog")
    objDialog.Filter = "Select Oracle Backup file|*.dat|All Files|*.*"
    objDialog.FilterIndex = 1
    objDialog.InitialDir = "C:\"
    intResult = objDialog.ShowOpen
 
    If intResult = 0 Then
        Wscript.Quit
    Else
    intPos = InstrRev(objDialog.FileName,"\")
    objDialog.FileName = Mid(objDialog.FileName,intPos + 1)
    intPos1 = InstrRev(objDialog.FileName,".")
    objDialog.FileName = Left(objDialog.FileName,intPos1 - 1)

    Wscript.Echo objDialog.FileName

    End If

(in reply to sambaram)
 
 
Post #: 2
 
 RE: using Windows CommonDialog - 8/2/2005 4:39:55 AM   
  mbouchard


Posts: 1863
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
Not sure if it will work for what you want, but try GetBaseName

Set fso = CreateObject("Scripting.FileSystemObject")


GetTheBase = fso.GetBaseName(objDialog.FileName)

msgbox GetTheBase


_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to sambaram)
 
 
Post #: 3
 
 RE: using Windows CommonDialog - 8/2/2005 10:56:03 AM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
Try this...

set fso = createobject("scripting.filesystemobject")
set file = fso.getfile("C:\My Documents\test.txt")
SimpleName = Replace(file.name, fso.GetExtensionName(file),"")


_____________________________

Fred

(in reply to mbouchard)
 
 
Post #: 4
 
 RE: using Windows CommonDialog - 8/4/2005 9:35:27 AM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
But I can't use this code because I get an "ActiveX" error.
Any help?

_____________________________

Fred

(in reply to Fredledingue)
 
 
Post #: 5
 
 RE: using Windows CommonDialog - 8/4/2005 9:53:49 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
This works for me (W 2000):

  Dim oCDlg

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

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

  oCDlg.ShowOpen

  WScript.Echo oCDlg.Filename  ' FSpec

(in reply to Fredledingue)
 
 
Post #: 6
 
 RE: using Windows CommonDialog - 8/4/2005 11:04:54 AM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
hey, thanks ebvhs,

The problem is that I'm on W98SE and many of the codes here don't work for me...and I don't know what I should download to ugrade my system for these functions and even if it's possble on W98.
Here I can't CreateObject( "MSComDlg.CommonDialog" ), just the same error as always.

_____________________________

Fred

(in reply to ehvbs)
 
 
Post #: 7
 
 RE: using Windows CommonDialog - 8/4/2005 11:38:38 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Fredledingue,

yes, you need the (installed and registered) .ocx for the CreateObject() calls. Have a look at

   http://support.microsoft.com/?kbid=168917
   http://support.microsoft.com/kb/159923/EN-US/

or (as an alternative)

   http://www.vbaccelerator.com/home/VB/Code/Libraries/Common_Dialogs/Common_Dialog_Direct/article.asp

I use "MSComDlg.CommonDialog" on a W 95 computer; but I don't know what product ( MS Office / VC++ 6.0 /
VBCCE ) provided the .ocx.

(in reply to Fredledingue)
 
 
Post #: 8
 
 RE: using Windows CommonDialog - 8/4/2005 12:17:56 PM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
Maybe I must update Comdlg32.ocx , but I'm not sure and I don't know where to find the last update for this file.
Those I found with Google were older than the one I have already.

_____________________________

Fred

(in reply to ehvbs)
 
 
Post #: 9
 
 RE: using Windows CommonDialog - 8/4/2005 8:21:01 PM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Fredledingue,

to cite Zifter: look at

   http://www.visualbasicscript.com/tm.aspx?m=2884

Did you register Comdlg32.ocx?
Do you use IE/HTML, IE/HTA, or C/WSript.exe?

(in reply to Fredledingue)
 
 
Post #: 10
 
 RE: using Windows CommonDialog - 8/5/2005 2:03:21 AM   
  mbouchard


Posts: 1863
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
If you havn't installed the latest version of WSH (5.6) on 98 you can get it here http://www.microsoft.com/downloads/details.aspx?FamilyId=0A8A18F6-249C-4A72-BFCF-FC6AF26DC390&displaylang=en

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to ehvbs)
 
 
Post #: 11
 
 RE: using Windows CommonDialog - 8/5/2005 3:45:46 AM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
thanks for your help,

I registered the ocx and have WSH5.6 installed. but I think it's more complicated than that: I should have a license (as I'v read) or install .NET...
But I'm still not sure I jhave the lastest Comdlg32.ocx. if you know where I can download it...


ehvbs,
I'm using in WSH, (wscript.exe) only...

_____________________________

Fred

(in reply to mbouchard)
 
 
Post #: 12
 
 RE: using Windows CommonDialog - 8/5/2005 5:04:45 AM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Fredledingue,

you may try

   http://www.ascentive.com/support/new/support_dll.phtml?dllname=COMDLG32.OCX

at your own risk; I don't know nothing about this site.

As told on

   http://support.microsoft.com/?kbid=168917

the .ocx is 'part' of VB 5.0 Control Creation Edition (VBCCE)

  cf http://support.microsoft.com/default.aspx?scid=kb;en-us;165524

If you download and install VBCCE you should qualify for the update mentioned on

  http://www.microsoft.com/downloads/details.aspx?familyid=25437D98-51D0-41C1-BB14-64662F5F62FE&displaylang=en

but again: not tested - ymmv.

(in reply to Fredledingue)
 
 
Post #: 13
 
 
 
  

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 >> using Windows CommonDialog 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