handofthrawn

Can't get _excel_bookattach to work anymore

4 posts in this topic

My script below was working as of last week but now the book won't attach.  The first error code is 1 for the book attach, @extended = -2147352570.  When I do the rangeread, it confirms the first error code with a 1 return.

I do have two excel sheets running but I didn't think it would matter because the book was attached to the file I want.  I've read the help file, tried the example scripts, even had this script working but now its broken.

My autoit is up to date.  Any ideals?  Thanks.

 

 

#include <Misc.au3>
#include <Excel.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <MsgBoxConstants.au3>


AutoItSetOption("WinTitleMatchMode", 2)
WinActivate("Morning IND")
Global $sWorkbook = @DesktopDir & "\Morning IND.xls"
Global $oExcel = _Excel_BookAttach($sWorkbook) ; Path to excel file that is on the desktop
If @error Then  MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Global $var1 = _Excel_RangeRead($oExcel, Default, "X47") ; Symbol from X1
If @error Then  MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

 

Share this post


Link to post
Share on other sites



If it worked and now it doesn't then something has changed:

  • The script code
  • The Excel workbook (name, directory where it is stored)
  • New version of AutoIt installed
  • New version of Excel installed
  • ...
     

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
On 4/7/2016 at 5:41 PM, water said:

I know this is an old thread but I wanted to thank water for the help.  I indeed messed up the directory and a couple other minor things.  Now I open everything in the correct order and it all works.  Thanks for making me double check the simple stuff.

 

Share this post


Link to post
Share on other sites

:) Glad it is again working now and that the problem was not caused by the Excel UDF (bug or whatever).

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • HSBen
      By HSBen
      If I have workbook open and active besides CardID.xlsm open, the script blows up.   Is there anyway to fix this, CardID.xlsm is always open, but if I want to also work in Excel my script basically doesn't function.
       
      Local $sWorkbook = "CardID.xlsm"
      $oWorkbook = _Excel_BookAttach($sWorkbook, "filename")
      $oWorkbook.parent.run("Run");