|
-
Mar 1st, 2013, 10:09 AM
#1
Thread Starter
Junior Member
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
-
Mar 1st, 2013, 10:17 AM
#2
Addicted Member
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.
-
Mar 1st, 2013, 10:19 AM
#3
Thread Starter
Junior Member
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.
-
Mar 1st, 2013, 11:59 AM
#4
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.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|