Run macro on excel file being viewed by a different computer
With both computers on the same network, one can access the other, but is there a way to run a macro in an excel that is currently being used by a different user, so that it updates in front of the other user?
I am trying to get this code to work but not sure what needs to be changed:
Sub Main()
Dim fileTest As String = "N:\Temp\template.xlsm"
Try
Dim F As Short = FreeFile()
FileOpen(F, fileTest, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
FileClose(F)
Catch
Dim xl As Excel.Application = Marshal.GetActiveObject("Excel.Application")
xl.Visible = True
xl.Run("test2")
Exit Sub
End Try
Dim xl2 As New Excel.Application
Dim oTargetWb As Excel.Workbook
oTargetWb = xl2.Workbooks.Open(fileTest)
xl2.Run("test2")
oTargetWb.Save()
oTargetWb.Close()
xl2.Quit()
xl2 = Nothing
End Sub
Re: Run macro on excel file being viewed by a different computer
You might want to ask in the correct forum, which is Office Development. This forum is for VB.NET.
Re: Run macro on excel file being viewed by a different computer
Sorry I meant to mention that I want to use vb.net to do this. That code is what I have written for vb.net.
Re: Run macro on excel file being viewed by a different computer
Whist you will be using vb.net, the more general question is whether an Excel instance on one computer can respond to a remote connection, which, as MetalInquisitor suggests is probably only a question that someone with experience of using Office on a network wil be able to answer. I would certainly recommend at least a parallel question on the Office forum. If you get a positive from that we'll be in a position to consider how you might code for it.