Sign in to follow this  
Followers 0
kaotkbliss

File open gui

5 posts in this topic

I'm creating a gui (my first) that as of right now will open a file in excel. However, if there is a space in the path name, excel thinks it is a new file. Example "C:\Documents and settings" would come out as "C:\Documents.xls" "and.xls" and "setting.xls"

GUICreate("AFIB Strip Search",250,60)
$path_input=GUICtrlCreateInput("enter path",10,3,200,20)
$browse_button=GUICtrlCreateButton ("...",210,0)
$go_button=GUICtrlCreateButton("GO",150,30,40,25)
$exit_button=GUICtrlCreateButton("Exit",50,30,40,25)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
If $msg = $go_button Then
    $path = GUICtrlRead($path_input)
    Run("C:\Program Files\Microsoft Office\Office10\EXCEL.EXE "&$path)
ElseIf $msg = $browse_button Then
        $browse = FileOpenDialog("Open","C:\","(*.dbf)",1)
        GUICtrlDelete($path_input)
        $path_input=GUICtrlCreateInput($browse,10,3,200,20)
    ElseIf $msg = $exit_button Then
        Exit(1)
EndIf
WEnd

this is the beginning of a much larger program and I am already stuck.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites



Umm, have you tried quoting the target file path?

Run('"C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" "' & $path & '"')

Share this post


Link to post
Share on other sites

thank you, that worked.

I did not try that because in other scripts I have written the spaces didn't affect the open file procedure.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

That is entirely dependent on the program to which you are feeding the command line. Don't make assumptions. A good rule of thumb is to quote the path to the executable you are running, and quote any paths or parameters that have spaces in them (ie a single parameter that has a space, like the name of a service passed to sc.exe that has a space in it).

Share this post


Link to post
Share on other sites

Another way would be to use Short Path+Names 8.3

Run(FileGetShortName("C:\Program Files\Microsoft Office\Office10\EXCEL.EXE") & " " & $path) ;will result c:\progra~1\micros~1\... etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0