Jump to content

Reading Spreadsheet Row


Recommended Posts

Hello Nine. Shame on me! I was thinking that the compiled script would be started each time (run as Administrator) then the hot key combination. Your approach is the right one. Now I'm wrestling with 2 other problems. First, I have the excel spreadsheet open on the desktop but when I start the compiled script, a second instance of the spreadsheet opens. This, of course, generates an error. If I close this second spreadsheet then use the hot key combo, the chosen row is displayed as expected. Naturally, I don't want this second instance. I suppose this could be a Windows 10 problem and not the script. My second problem is that I'm trying to use the script to send the captured row information to another app which is open on the desktop. I've been able to do that with the script posted by Subz so I know my code works. Any answers would be appreciated.

Link to comment
Share on other sites

Use _Excel_BookAttach instead of _Excel_BookOpen.  That will solve your first issue.

For the second problem, post the code you have, so I can look to it.  Crystal ball is out of service...

Link to comment
Share on other sites

Thanks for the response. I made the change and am now getting this error:

"E:\Newburyport\2020_personalizingForms\NBP-TestScript.au3" (20) : ==> Variable must be of type "Object".:
Local $oRange = $oWorkBook.Activesheet.UsedRange.Rows($oExcel.ActiveCell.row)
Local $oRange = $oWorkBook^ ERROR
>Exit code: 1    Time: 13.14

Link to comment
Share on other sites

Do you have a reading problem ?  Looks to me that you have difficulties to understand what we are suggesting you to do ?

I will repeat, post your code, so we can help you and stop telling us stories that it doesn't work.

Edited by Nine
Link to comment
Share on other sites

First, I understand perfectly - English is my native language.  The error info I posted occurs when I run your code alone after making the change you suggested. However, the remainder of the script calls and inserts the captured data into a proprietary application and I'm very reluctant to post the code for it on a public site. The point is, and I repeat, this error occurs when I run your code by itself. I've attached your code modified per your instructions.

NBP-TestScript2.au3

Link to comment
Share on other sites

I see, your _Excel_BookAttach is wrongly constituted.  Please open help file and read carefully how the parameters are passed to the function.

When you have issues within a script, add some error handling, it will help you understand what is going on...

Edited by Nine
Link to comment
Share on other sites

I've tried compiling this script in both x86 and x64. It compiles without errors and runs when the .exe is run using Open or double click. However, when run as administrator a second blank Excel window opens and the program crashes (Line 3827 - Error: The requested action with this object has failed) when the hotkey combo is used. I need to run this script using the as administrator function. I've tried many, many changes without success. Any help would be appreciated.

NBP-TestScript2.au3

Link to comment
Share on other sites

Try something like: (untested)

Global $oWorkbook
    ;~ Try to attach to open workbook
    $oWorkbook = _Excel_BookAttach($sWorkbook)
        ;~ If unable to attach to the workbook, open the workbook
        If @error Then $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
            If @error Then Exit MsgBox(4096, "Error opening workbook", "Error occurred while trying to open: " & @CRLF & $sWorkbook)

 

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...