Fraser Posted September 12, 2014 Posted September 12, 2014 Good Afternoon, I'm trying to get the link source of a load of excel file and then change them to a new link, however for some reason when I use _excelbookopen to open the book I can't then use the returned object to get the link source ($aLinks = $oExcel.LinkSources($xlExcelLinks)) here is the code so far: expandcollapse popup#include <array.au3> #include <file.au3> #include <excel.au3> Dim $Filename Dim $xlsApp Dim $objWorkbook Dim $i Dim $newSheet Dim $docs $strFileNamelinkinfo = "C:\Users\User\desktop\output.csv" $Filename = "C:\Users\User\desktop\file_names.txt" ReadFile($Filename) Func ReadFile($AFileName) _FileReadToArray($Filename, $docs) If IsArray($docs) Then _ArrayDisplay($docs) _ArrayDelete($docs, 0) For $file in $docs ListLinks($file) Next EndIf EndFunc Func ListLinks($strFileName) Dim $aLinks Const $xlExcelLinks = 1 $oExcel = _ExcelBookOpen($strFileName) $oExcel = ObjGet("", "Excel.Application") msgbox(0, "", $oExcel) $aLinks = $oExcel.LinkSources($xlExcelLinks) _ExcelBookClose($oExcel, 0, 0) If IsArray($aLinks) Then msgbox(0, "", "Links returned") EndIf Endfunc Any suggestions? Thanks Jamie
water Posted September 12, 2014 Posted September 12, 2014 So you are using AutoIt 3.3.8.1 or older? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted September 12, 2014 Posted September 12, 2014 LinkSources is a method of the Workbook object, not the application object. expandcollapse popup#include <array.au3> #include <file.au3> #include <excel.au3> Dim $Filename Dim $xlsApp Dim $objWorkbook Dim $i Dim $newSheet Dim $docs $strFileNamelinkinfo = "C:\Users\User\desktop\output.csv" $Filename = "C:\Users\User\desktop\file_names.txt" ReadFile($Filename) Func ReadFile($AFileName) _FileReadToArray($Filename, $docs) If IsArray($docs) Then _ArrayDisplay($docs) _ArrayDelete($docs, 0) For $file in $docs ListLinks($file) Next EndIf EndFunc Func ListLinks($strFileName) Dim $aLinks Const $xlExcelLinks = 1 $oExcel = _ExcelBookOpen($strFileName) ; Returns the Excel application object $aLinks = $oExcel.ActiveWorkbook.LinkSources($xlExcelLinks) _ExcelBookClose($oExcel, 0, 0) If IsArray($aLinks) Then msgbox(0, "", "Links returned") EndIf Endfunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted September 12, 2014 Posted September 12, 2014 The Excel UDF in 3.3.8.1 will be very slow because you open and close Excel for every workbook. When you upgrade to the latest Autoit version you will see a big performance gain because you open Excel once, process all workbooks and then close Excel again. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Fraser Posted September 12, 2014 Author Posted September 12, 2014 (edited) Hi, Thanks for getting back to me. I am running an older version of autoit (3.3.0) this is the only version that I can get approved at work at the moment, I have submitted a case to allow me to install the latest version however this can take a while. That makes scene, works in a similar manner as VB where you specify the object and then the workbook, thank you for your help. Regards, Fraser Edited September 12, 2014 by Fraser
water Posted September 12, 2014 Posted September 12, 2014 If speed is an issue then you could split the functions so that even with an older version of AutoIt and the Excel UDF it doesn't take ages to process all files. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now