how to connect excel to vb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • giriab
    New Member
    • May 2007
    • 4

    how to connect excel to vb

    hi i have written one progrm in vb but i want its output in excel but i am not able to coonect excel to vb so plz help me
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by giriab
    hi i have written one progrm in vb but i want its output in excel but i am not able to coonect excel to vb so plz help me
    You need to add Microsoft Excel n.n Object Library in your project references.

    Comment

    • SammyB
      Recognized Expert Contributor
      • Mar 2007
      • 807

      #3
      Originally posted by giriab
      hi i have written one progrm in vb but i want its output in excel but i am not able to coonect excel to vb so plz help me
      Which VB? VBA (which application), VB6, or VB.NET? Do you want to use ADO or access Excel directly?

      Comment

      • giriab
        New Member
        • May 2007
        • 4

        #4
        Originally posted by SammyB
        Which VB? VBA (which application), VB6, or VB.NET? Do you want to use ADO or access Excel directly?
        vb6 and i want to access excel directly

        Comment

        • giriab
          New Member
          • May 2007
          • 4

          #5
          Originally posted by Killer42
          You need to add Microsoft Excel n.n Object Library in your project references.
          how to add the object library

          Comment

          • SammyB
            Recognized Expert Contributor
            • Mar 2007
            • 807

            #6
            Originally posted by giriab
            how to add the object library
            No VB6 here, but it maybe the Tools, References menu. Maybe even Ctrl R. In any case, it's the References or Add References menu. Here's a thread with some of the objects you'll need, http://www.thescripts.com/forum/thread641830.html

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by SammyB
              No VB6 here, but it maybe the Tools, References menu. Maybe even Ctrl R. In any case, it's the References or Add References menu...
              It's under Project | References.

              Comment

              • SammyB
                Recognized Expert Contributor
                • Mar 2007
                • 807

                #8
                Originally posted by Killer42
                It's under Project | References.
                How quick we forget!

                Comment

                • CaptainD
                  New Member
                  • Mar 2006
                  • 135

                  #9
                  Originally posted by giriab
                  hi i have written one progrm in vb but i want its output in excel but i am not able to coonect excel to vb so plz help me

                  Code:
                  Private Sub Command1_Click()
                  Dim oXLApp As Excel.Application
                  
                  Dim strPath As String
                  strPath = "PathToWorksheet"
                  Set oXLApp = New Excel.Application
                  Set oxlBook = oXLApp.Workbooks.Open(strPath)
                  Set Worksheet = oXLApp.Worksheets(1)
                  
                  oXLApp.Visible = True  'If you want to open the workbook
                  
                  End Sub

                  Comment

                  Working...