Results 1 to 4 of 4

Thread: Run macro on excel file being viewed by a different computer

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    24

    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

  2. #2
    Addicted Member MetalInquisitor's Avatar
    Join Date
    Sep 2012
    Posts
    143

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    24

    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.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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
  •  



Click Here to Expand Forum to Full Width