Markir Posted March 21, 2005 Share Posted March 21, 2005 Hello, I want to open the test.xls file by clicking on a button, but I Don't know how to do that. I know, how I can run a program and this function already. Can somebody help me please? Link to comment Share on other sites More sharing options...
Markir Posted March 23, 2005 Author Share Posted March 23, 2005 Has somebody an idea? Link to comment Share on other sites More sharing options...
Joel Posted March 23, 2005 Share Posted March 23, 2005 (edited) Run(@ComSpec & " /c start " & "test.xls") If incorporating it with a button in a gui app: $button = GUICtrlCreateButton ("YourButton", ###, ###, ###, ###) While 1 $msg = GUIGetMsg () If $msg = $button Then Run(@ComSpec & " /c start " & "test.xls") Wend Here that's a little cleaner for you. The ###,###,###,### are the positional numbers related to left, top, width, height. So, you have to use actual numbers there in relation to where your button is in the app. Edited March 23, 2005 by Joel [font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font] Link to comment Share on other sites More sharing options...
Markir Posted March 31, 2005 Author Share Posted March 31, 2005 Hello Joel, I have now your code in my program, but there must I code a line Send("123")? If I make thsi line between the While Code it will be looped #include <GUIConstants.au3> Global $msg, $button GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetState (@SW_SHOW) ; will display an empty dialog box $button = GUICtrlCreateButton("Excel öffnen",100,100) While 1 $msg = GUIGetMsg () If $msg = $button Then Run(@ComSpec & " /c start " & "C:\test.xls") Wend Link to comment Share on other sites More sharing options...
Markir Posted April 21, 2005 Author Share Posted April 21, 2005 Is it possible that you can go to a special field in the excel sheet, like "B3"? Link to comment Share on other sites More sharing options...
mikezwet2 Posted April 21, 2005 Share Posted April 21, 2005 Maybe with tab button and arrow buttons? Send("{TAB}") I dont know how to give a sign that goes directly to B3 or something else Zwetsloot Kunststof Kozijnen Fabriek and Mike Zwetsloot Link to comment Share on other sites More sharing options...
herewasplato Posted April 21, 2005 Share Posted April 21, 2005 Is it possible that you can go to a special field in the excel sheet, like "B3"?<{POST_SNAPBACK}>Send("^g")WinWait("Go To")Send("B3{ENTER}") [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Markir Posted April 23, 2005 Author Share Posted April 23, 2005 Hello, I have now the following Code, but with this code, the special excel file will not be openend? Why is it so? #include <GUIConstants.au3> Global $msg, $button GUICreate("My GUI") $button = GUICtrlCreateButton("Button",100,100) GUICtrlSetOnEvent(-1, "Button") GUISetState () While 1 Sleep(10) Wend Func Button() RUN(@ComSpec & " /c start " & "C:\test.xls") Send("^g") WinWait("Go To") Send("B3{ENTER}") EndFUnc Link to comment Share on other sites More sharing options...
herewasplato Posted April 23, 2005 Share Posted April 23, 2005 Hello,I have now the following Code, but with this code, the special excel file will not be openend? Why is it so?#include <GUIConstants.au3> Global $msg, $button GUICreate("My GUI") $button = GUICtrlCreateButton("Button",100,100) GUICtrlSetOnEvent(-1, "Button") GUISetState () While 1 Sleep(10) Wend Func Button() RUN(@ComSpec & " /c start " & "C:\test.xls") Send("^g") WinWait("Go To") Send("B3{ENTER}") EndFUnc<{POST_SNAPBACK}>RUN(@ComSpec & " /c start " & "C:\test.xls") should work if C:\test.xls is really the path to the file.Try RUN("---your path to excel.exe C:\test.xls")it is not as portable but might work for your needsAlso, you should not send the ^g to the excel application until it has finished loading and the window is active. Read the help file on WinWait and WinActivate. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
buzz44 Posted April 23, 2005 Share Posted April 23, 2005 (edited) Why put an '&' between the words if you arn't using a variable? Run(@ComSpec & " /c start C:\test.xls") and I think it's. Run('---your path to excel.exe "C:\test.xls"') If not then the qoutation marks need to be swapped. Edited April 23, 2005 by Burrup qq Link to comment Share on other sites More sharing options...
Markir Posted April 24, 2005 Author Share Posted April 24, 2005 Hello, now I have use the following code: RUN ("C:\Programme\Microsoft Office\OFFICE11\Excel.exe"), but it doesn't work. Excel will not be opened. Link to comment Share on other sites More sharing options...
phillip123adams Posted April 24, 2005 Share Posted April 24, 2005 RUN ("C:\Programme\Microsoft Office\OFFICE11\Excel.exe"), but it doesn't work. Excel will not be opened.<{POST_SNAPBACK}>It needs additional quotes because the path contains a space character. Try this:RUN ('"C:\Programme\Microsoft Office\OFFICE11\Excel.exe"') Phillip Link to comment Share on other sites More sharing options...
Markir Posted April 24, 2005 Author Share Posted April 24, 2005 Sorry, but your code to help me wasn't right, it doesn't start Excel Link to comment Share on other sites More sharing options...
phillip123adams Posted April 24, 2005 Share Posted April 24, 2005 Sorry,but your code to help me wasn't right, it doesn't start Excel<{POST_SNAPBACK}>What does it do? Do you have the correct path? You can copy the path and filename from an Excel icon and paste it in the Run function.Here's what runs Excel on my system (I've tested it and it works):RUN ('"C:\Program Files\Microsoft Office\Office10\EXCEL.EXE"') Phillip Link to comment Share on other sites More sharing options...
phillip123adams Posted April 24, 2005 Share Posted April 24, 2005 #include <GUIConstants.au3> GUICreate("My GUI") $button = GUICtrlCreateButton("Button",100,100) GUICtrlSetOnEvent(-1, "Button") GUISetState () While 1 Sleep(10) Wend Func Button() RUN ('"C:\Programme\Microsoft Office\Office10\EXCEL.EXE"') EndFUnc<{POST_SNAPBACK}>You did not set GUIOnEventMode. Without it, the event does not fire when the button is clicked.opt("GUIOnEventMode", 1) Phillip Link to comment Share on other sites More sharing options...
Markir Posted April 24, 2005 Author Share Posted April 24, 2005 Thank you now it works, it was a simple litlle mistake, in another program I have set this code :-( Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now