Attaching Excel Sheet

Get help with using AutoHotkey and its commands and hotkeys
Indhu
Posts: 6
Joined: 17 Apr 2019, 05:43

Attaching Excel Sheet

17 Apr 2019, 06:17

Hello people,
I'm trying to attach an excel sheet, with my script, so that I can have my excel sheet data into clipboard, from which I can use those in a seperate application. I started off like in the following code, but I keep on getting this error "The following variable name contains an illegal character: 'XL.Visible'. The program will exit."
When I tried to make that line as comment, I got another error, saying, "Call to non-existent function" at "ComObjCreate("Excel.Application")". If I try something else, I get an error again at my file path, saying "The leftmost character in the above expression is invalid". So what shall I do to make it work?

Thanks in advance

This is my script.

Code: Select all


Path := "%A_Desktop%\Data\Input.xlsx"
XL := ComObjCreate("Excel.Application")
XL.Workbooks.Open(Path)
XL.Visible := True

User avatar
Tigerlily
Posts: 277
Joined: 04 Oct 2018, 22:31

Re: Attaching Excel Sheet

17 Apr 2019, 06:36

Indhu wrote:
17 Apr 2019, 06:17
Hello people,
I'm trying to attach an excel sheet, with my script, so that I can have my excel sheet data into clipboard, from which I can use those in a seperate application. I started off like in the following code, but I keep on getting this error "The following variable name contains an illegal character: 'XL.Visible'. The program will exit."
When I tried to make that line as comment, I got another error, saying, "Call to non-existent function" at "ComObjCreate("Excel.Application")". If I try something else, I get an error again at my file path, saying "The leftmost character in the above expression is invalid". So what shall I do to make it work?

Thanks in advance

This is my script.

Code: Select all


Path := "%A_Desktop%\Data\Input.xlsx"
XL := ComObjCreate("Excel.Application")
XL.Workbooks.Open(Path)
XL.Visible := True

You are combining Expression and Legacy Syntax (please read this AHK docs page). When using Excel COM, I would try to exclusively stick to Expression syntax, if possible.

try this:

Code: Select all


Path := A_Desktop "\Data\Input.xlsx"
XL := ComObjCreate("Excel.Application")
XL.Workbooks.Open(Path)
XL.Visible := True

-TL
Indhu
Posts: 6
Joined: 17 Apr 2019, 05:43

Re: Attaching Excel Sheet

17 Apr 2019, 06:56

@Tigerlily

Hello TL, tried your way. Still the same error with file path, " The leftmost character above is illegal in an expression".
-I :)
User avatar
gregster
Posts: 2133
Joined: 30 Sep 2013, 06:48

Re: Attaching Excel Sheet

17 Apr 2019, 10:38

Please show your updated code that causes this error message.
Indhu
Posts: 6
Joined: 17 Apr 2019, 05:43

Re: Attaching Excel Sheet

Yesterday, 00:12

This was my code, after the above suggesstion

Code: Select all


Path := A_Desktop"\Data\Input.xlsx"
XL := ComObjCreate("Excel.Application")
XL.Workbooks.Open(Path)
XL.Visible := True


-I :)
AviationGuy
Posts: 151
Joined: 17 Jan 2019, 10:13

Re: Attaching Excel Sheet

Yesterday, 03:07

Try adding a space after A_Desktop, works for me that way.
Good luck!
Indhu
Posts: 6
Joined: 17 Apr 2019, 05:43

Re: Attaching Excel Sheet

Yesterday, 04:12

Nope..Still shows 'XL.Visible' contains illegal character. :( @AviationGuy
-I :)
Kobaltauge
Posts: 68
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: Attaching Excel Sheet

Yesterday, 05:28

The script is running here. My input.xlsx was an empty excel sheet. Probably there is a problem with the file. Replace it of a test.
Indhu
Posts: 6
Joined: 17 Apr 2019, 05:43

Re: Attaching Excel Sheet

Yesterday, 05:49

@Kobaltauge

The same error again :( . Is there any issue with 'XL.Visible'?
-I :)
Indhu
Posts: 6
Joined: 17 Apr 2019, 05:43

Re: Attaching Excel Sheet

Yesterday, 05:56

This is the error message I get everytime
@Kobaltauge
ER.PNG
ER.PNG (16.56 KiB) Viewed 68 times
-I :)
User avatar
gregster
Posts: 2133
Joined: 30 Sep 2013, 06:48

Re: Attaching Excel Sheet

Yesterday, 09:10

Perhaps you copy/pasted an invisible character from somewhere into your script. Try to delete the line and type it again by hand...

Edit: Which AHK version are you using (and which bitness? ANSI/Unicode?) ?
AviationGuy
Posts: 151
Joined: 17 Jan 2019, 10:13

Re: Attaching Excel Sheet

Yesterday, 09:34

Strange, it should work this way. Try @gregster's suggestion, maybe this is the case.
Also, what do you have on top of your script, since this is line 6...?

Return to “Ask For Help”

Who is online

Users browsing this forum: creative, DataLife, Evil-e, Google [Bot], SonGokuBg, TAC109, vsub and 37 guests