Jump to content

Open an special excel file test.xls


Recommended Posts

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]

Link to comment
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
Link to comment
Share on other sites

  • 3 weeks later...

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

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]

Link to comment
Share on other sites

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

qq

Link to comment
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

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...