So i want to be able to start an excel macro in a file that is already opened by a user. Like a user would open the excel file and look at it, but when there is new data, my vb.net program will run, call out the macro in the opened file and update the excel file in front of the user. Is this something that is possible?
Every time I try to get this done it runs the macro of the opened file but doesn't update it. Instead it saves it over the excel file, so you have to close the excel file and reopen it to see the new data. But I don't want to have to do that.
Here is my code used for this instance:
Dim xl As New Excel.Application
Dim oTargetWb As Excel.Workbook
oTargetWb = xl.Workbooks.Open(fileTest)
Try
Dim F As Short = FreeFile()
FileOpen(F, fileTest, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
FileClose(F)
Catch
xl.Run("test2")
End Try
Any suggestions?
Every time I try to get this done it runs the macro of the opened file but doesn't update it. Instead it saves it over the excel file, so you have to close the excel file and reopen it to see the new data. But I don't want to have to do that.
Here is my code used for this instance:
Dim xl As New Excel.Application
Dim oTargetWb As Excel.Workbook
oTargetWb = xl.Workbooks.Open(fileTest)
Try
Dim F As Short = FreeFile()
FileOpen(F, fileTest, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
FileClose(F)
Catch
xl.Run("test2")
End Try
Any suggestions?