We are on the right track. This looks promising Being a newbie, how do I trigger this event or pass info to this sub once Excel has updated. Many thanks Jeremy
clockit
Posts
-
Excel feedback in VB6 -
Excel feedback in VB6:(Hi all who know all I have a problem in that I need to automate an excel spreadsheet with external data sources and update the data from a remote server. Problem is, this is a standard spreadsheet which I cannot (not allowed) change yet want to read certain data from it once it has updated. Starting Excel and automating the update is not a problem (see code below). However, I need to know when the update is complete since I then have to extract specific data from this spreadsheet in my code in VB to use. How can I get feedback from Excel to say that the update is complete or alternatively pass execution to another piece of code once the update is done. "Command1_Click" section of code works fine - its the "AfterRefresh" bit thats got me stumped since it don't work!!!!!!!! The "AfterRefresh" section apparently refers to a PivotTable according to the excel Help section but I am not using a PivotTable. Any help would be GREATLY appreciated Regards Jeremy Private Sub Command1_Click() Set m_objExcel = Excel.Workbooks Dim msExcelWorkbook As String msExcelWorkbook = App.Path & "\ExcelReports\Update.xls" m_objExcel.Open msExcelWorkbook m_objExcel.Application.Visible = True m_objExcel.Application.ActiveWorkbook.RefreshAll End Sub Private Sub ActiveWorkBook_AfterRefresh(Success As Boolean) If Success = True Then m_objExcel.Application.ActiveWorkbook.Save m_objExcel.Application.ActiveWorkbook.Close m_objExcel.Application.Quit Call MsgBox("Refreshed all Data", vbOKOnly) Else ' failed or was cancelled End If End Sub