Sign in to follow this  
Followers 0
superstylink

open excel file

18 posts in this topic

Hi I'm a php programmer first time playng with autoit , I think it's coll but I've some problem trying to strat an excel file with a macro insed

I've customized the one in the help file buit it doens't work , the ese I creted is in the same dir of excel file ... any help

thanx in advance

this is the code ,

$file = FileOpen("events.xls", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileClose($file)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi I'm a php programmer first time playng with autoit , I think it's coll but I've some problem trying to strat an excel file with a macro insed

I've customized the one in the help file buit it doens't work , the ese I creted is in the same dir of excel file ... any help

thanx in advance

this is the code ,

$file = FileOpen("events.xls", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileClose($file)
Think you want to open the file with Excel .... right ?

try running the file with start or run Excel.exe ....

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

yeah, to add to what jdeb said, FileOpen is just for opening text files for AutoIt to proccess...

run("c:\prg files\office\excel.exe c:\mydocs\file.xls") should open the file...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

ciao JdeB and thanx for your fast answer

yes I like to run the events.xls file but the macro I created in it run it in hide way and create a csv in a different directory , is it possible use this snippet to run excel file as the txt file in the example

Share this post


Link to post
Share on other sites

ciao JdeB and thanx for your fast answer

yes I like to run the events.xls file but the macro I created in it run it in hide way and create a csv in a different directory , is it possible use this snippet to run excel file as the txt file in the example

prego...

but i am somewhat puzzled what it is you want to accomplish here.

could you explain again which steps you want to do in the script ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

very easy I created a macro in vb insiede an excel file it does a webquery and save in a different directory a csv file well my macro end s here all the job its done in hidden window command

now with autoit I like to do an exe that call this macro inside result.xls file that's all

I used the cose snippet openfile function but it doesn't work

Share this post


Link to post
Share on other sites

when you run excel like emmanuel suggest, won't that work ?

In other words, does your macro automatically start up when events.xls is openend, and close the Excel file when finished ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

if the macro doesn't autostart, you could set a hotkey for it (in excel)and then send that hotkey from autoit...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

yes I try what emmanuel suggested but I 've this error

error: unable to execute the external program but before it fired up excel application so the problem is the singlòe file not the application

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

can you show the code that failed?

these failures are most often caused by syntax problems...

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

yes emanuel my macro has Auto_Open() function and hidden window command and my excel is setted to run macro in auto

Share this post


Link to post
Share on other sites

run("C:\Programmi\Microsoft Office\OFFICE11\EXCEL.EXE C:\Programmi\Q2 Tuner\data\results.xls")

Share this post


Link to post
Share on other sites

This might help, I bet the Run command isn't liking the spaces, so we use some creative double quotes

run('"C:\Programmi\Microsoft Office\OFFICE11\EXCEL.EXE" "C:\Programmi\Q2 Tuner\data\results.xls"')
The single quotes on the outside make it all one run command for autoit to send, and the double quotes inside help windows figure out what you're doing...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

thanx a lot guys now it works perfect ;-) , maybe it was a escape like problem as u u told me .

I 'd like to to read some advanced tuts coud u tell me where I can find some snippet or tutorial about autoit programming

ciao

Share this post


Link to post
Share on other sites

browse the scripts and scraps section, the autoit install includes an examples folder and the includes are good for more advanced examples...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Emmanuel.. your explanation of the use of 'quotes' and "double quotes" is the best I have seen to explain their use. Now it all makes sense.. the light :ph34r: just came on. Thanks.

Share this post


Link to post
Share on other sites

Emmanuel.. your explanation of the use of  'quotes'  and  "double quotes" is the best I have seen to explain their use.  Now it all makes sense.. the light  :ph34r:  just came on.  Thanks.

glad to have helped!

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

HI guys I'm implementing another piece of code on my little utility

as I told u my prog create 2 csv file in a backup directory weel this task is ok now as I told , now I'm trying to implement a progress bar window that stops when the 2 file are created

this is my meta code

------------------------

$firstcsv=namefirstcsv.csv

$secondcsv=namesecondcsv.csv

while // loop

($firstcsv !=0 $seconcsv !=0) {

ProgressOn("my progress window", "creating csv files ", "0 percent")

ProgressOff()}

-----------------------

any suggestion on how to do it in autoit coding syntax?

TIA

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