Socket Programming in VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Han Nan
    New Member
    • Jul 2010
    • 3

    Socket Programming in VBA

    Hi,

    I am trying to create a software which has client-server model. Is there any way to make two separate excel sheets talk to each other?
    The current version is in C++ which uses a server and a client method based on ip and port number. Can we do something similar in VBA?


    Thanks,
    Han Nan
  • maxamis4
    Recognized Expert Contributor
    • Jan 2007
    • 295

    #2
    Programming expierence

    Just to give you an idea if it is Microsoft it can talk to it. My question is to you is how much coding experience do you have with VBA.

    If you look at this snippet of code it will give you an idea of what to do:

    Code:
    Dim cn as ADODB.Connection
    Set cn = New ADODB.Connection
    With cn
    	.Provider = "Microsoft.Jet.OLEDB.4.0"
    	.ConnectionString = "Data Source=C:\MyFolder\MyWorkbook.xls;" & _
    "Extended Properties=Excel 8.0;"
    	.Open
    End With

    Comment

    • Han Nan
      New Member
      • Jul 2010
      • 3

      #3
      Originally posted by maxamis4
      Just to give you an idea if it is Microsoft it can talk to it. My question is to you is how much coding experience do you have with VBA.

      If you look at this snippet of code it will give you an idea of what to do:

      Code:
      Dim cn as ADODB.Connection
      Set cn = New ADODB.Connection
      With cn
      	.Provider = "Microsoft.Jet.OLEDB.4.0"
      	.ConnectionString = "Data Source=C:\MyFolder\MyWorkbook.xls;" & _
      "Extended Properties=Excel 8.0;"
      	.Open
      End With
      Hi,

      Thanks for the code.
      I am getting User-type not defined at "cn As ADODB.Connectio n".
      Also, this is just to establish a connection. What I want to do is say from sheet 1 I pass a string "Hi this is me". and in sheet 2 I received a message with option OK & Cancel and update this message to the selected row.
      Any idea how to do this??

      Please help.

      Thanks,
      Han Nan

      Comment

      • MrDeej
        New Member
        • Apr 2007
        • 157

        #4
        You need to make a reference for "Microsoftf Activex Data objects " in the VBA windows

        Comment

        • Oralloy
          Recognized Expert Contributor
          • Jun 2010
          • 988

          #5
          Just a quick thought ... why are you even trying to network this?

          If the sheets are on the same computer, just have the first one open the second under excel, and then execute methods that live in that sheet? Easy Peasey.

          If you need a more complex interaction or an actual client/server model over the network, let us know.

          Comment

          • Han Nan
            New Member
            • Jul 2010
            • 3

            #6
            Hi,

            The excel sheets may or may not be on the same computer...so if there is a person in Location A and another person in Location B logging on to the same server then how do we tackle this situation?

            Thanks,
            Han Nan

            Comment

            • Oralloy
              Recognized Expert Contributor
              • Jun 2010
              • 988

              #7
              Han,

              (Or, should I address you as Nan?)

              Hopefully you have a good idea of how to craft a client-server system. It's not difficult, but the devil is in the details.

              You might want to look at this article:

              As a starting point.

              Luck!

              Comment

              Working...