Sign in to follow this  
Followers 0
Markir

Open an special excel file test.xls

16 posts in this topic

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?

Share this post


Link to post
Share on other sites

Has somebody an idea?

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Joel

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Is it possible that you can go to a special field in the excel sheet, like "B3"?

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 needs

Also, 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]

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Sorry,

but your code to help me wasn't right, it doesn't start Excel

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

Thank you now it works, it was a simple litlle mistake, in another program I have set this code :-(

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