Spring Posted August 29, 2017 Share Posted August 29, 2017 Hello, I have an excel file that I need to open from a SharePoint site, refresh all, then save and close. Problem is, the excel doc opens in read only. So while I can open, refresh and close the document, it will not save. To do this manually, I just have to hit the Edit Workbook button at the top of the document. Anyone know of a way to get this to work? Any help would be appreciated. My current script is below #include <Excel.au3> Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, "filenamefullpath") $oExcel.Workbooks(1).RefreshAll ; refresh _Excel_BookClose ( $oWorkbook , True ) _Excel_close ($oExcel) Link to comment Share on other sites More sharing options...
water Posted August 29, 2017 Share Posted August 29, 2017 Here you will find an idea how to checkout/modify/checkin a Excel workbook stored in SharePoint. 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 Link to comment Share on other sites More sharing options...
Spring Posted August 30, 2017 Author Share Posted August 30, 2017 Ok, forgive me, I have a VB macro that already does this. I just cant use the macro to run hourly on a shared computer, which is why I'm looking at AutoIt. Using a macro, I don't need the check in/check out anything. Here is my macro that works... How do I put the two together? Private Sub Auto_Open() ' RefreshMyDocs Application.Quit ' End Sub Private Sub RefreshMyDocs() RefreshDoc "myfile.xlsx" End Sub Private Sub RefreshDoc(AbsolutePathToFile As String) Dim W As Workbook Set W = Workbooks.Open(AbsolutePathToFile) EnableCalculation = True W.RefreshAll Application.DisplayAlerts = False W.SaveAs "myfile.xlsx", AccessMode:=xlExclusive, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges W.Close End Sub Link to comment Share on other sites More sharing options...
water Posted August 31, 2017 Share Posted August 31, 2017 As I understand it this macro is run by Excel when you open the Workbook. It Needs to be part ot the Excel file.https://bettersolutions.com/vba/events/auto-open.htm The AutoIt script is run as a separate program. I fear you can only combine this two parts by translating your AutoIt script to VBA and add it to the Workbook. Then call the function from Auto_Open. 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 Link to comment Share on other sites More sharing options...
Spring Posted August 31, 2017 Author Share Posted August 31, 2017 I cant use the VB in my spreadsheet do to the shared computer it needs ran on. There is already a macro called the same thing being ran on it so it will not work, which is why I thought AutoIt would be the best way to go. The link above sent me to a page with VB code, which is why i thought you were talking about macros. I can't use a macro for what i am trying to do... Link to comment Share on other sites More sharing options...
water Posted August 31, 2017 Share Posted August 31, 2017 I see. Translating the VBA macro to AutoIt isn't a big task. Will post an example as soon as I find some spare time. Spring 1 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 Link to comment Share on other sites More sharing options...
water Posted August 31, 2017 Share Posted August 31, 2017 Could be something like this: #include <Excel.au3> Local $sFullPath = "filenamefullpath" Local $xlExclusive = 3 ; Exklusive mode Local $xlLocalSessionChanges = 2 ; The local user's changes are always accepted Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sFullPath) $oWorkbook.Activesheet.EnableCalculation = True $oWorkbook.RefreshAll $oExcel.DisplayAlerts = False $oWorkbook.SaveAs("myfile.xlsx", Default, Default, Default, Default, Default, $xlExclusive, $xlLocalSessionChanges) _Excel_BookClose($oWorkbook, True) _Excel_Close($oExcel) Spring 1 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 Link to comment Share on other sites More sharing options...
Spring Posted September 14, 2017 Author Share Posted September 14, 2017 That works great on my computer, running Windows 10, does not work on my coworkers computer running Windows 7. Trying to run it on his computer will not refresh. It will open, save and close the file, but just the refresh does not work. Any ideas why? This should be compatible with 7, correct? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 14, 2017 Moderators Share Posted September 14, 2017 Since you're working in Excel, not with Windows, isn't the most likely consideration the application not the OS? Is he running the exact same version of Office as you are? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
water Posted September 14, 2017 Share Posted September 14, 2017 (edited) Which version of Office is he running on the Windows 7 machine? I was too slow Edited September 14, 2017 by water 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 Link to comment Share on other sites More sharing options...
Spring Posted September 14, 2017 Author Share Posted September 14, 2017 LOL, he has 2013, I am using 2016. Link to comment Share on other sites More sharing options...
water Posted September 14, 2017 Share Posted September 14, 2017 The RefreshAll method is available in Excel 2013 as well. You need to add a COM error handler so we know where the problem arises and all available error information. Please check ObjEvent in the help file for more details. 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 Link to comment Share on other sites More sharing options...
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