Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Creating an Excel Workbook in VB.NET 2008

Creating an Excel Workbook in VB.NET 2008

Scheduled Pinned Locked Moved Visual Basic
csharpcomquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Like2Byte
    wrote on last edited by
    #1

    Hi, I'm helping a colleague of mine. We're trying to create an Excel workbook so he can do some calculations. However, we can't get the excel object to instantiate. We've added the reference via 'Project->Add Reference->Microsoft Excel 11.0 Object Library->OK. On our form, we've added the following but can not get the object to instantiate. Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim excelapp As New Microsoft.Office.Interop.Excel.Application Dim excelwb As Microsoft.Office.Interop.Excel.Workbook End Class The Dim calls seem to take ok as no squiggly lines appear on those two lines. Attempting to reference excelapp or excelwb only results in squiggly lines under their names and no properties will appear in the drop down - that is, there is no dropdown as it doesn't recognize the two variables. How can we instantiate the excel object so we can use the methods on it? Thanks in advance. :)

    D 1 Reply Last reply
    0
    • L Like2Byte

      Hi, I'm helping a colleague of mine. We're trying to create an Excel workbook so he can do some calculations. However, we can't get the excel object to instantiate. We've added the reference via 'Project->Add Reference->Microsoft Excel 11.0 Object Library->OK. On our form, we've added the following but can not get the object to instantiate. Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim excelapp As New Microsoft.Office.Interop.Excel.Application Dim excelwb As Microsoft.Office.Interop.Excel.Workbook End Class The Dim calls seem to take ok as no squiggly lines appear on those two lines. Attempting to reference excelapp or excelwb only results in squiggly lines under their names and no properties will appear in the drop down - that is, there is no dropdown as it doesn't recognize the two variables. How can we instantiate the excel object so we can use the methods on it? Thanks in advance. :)

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #2

      I tried the following;

      Imports Microsoft.Office.Interop.Excel

      Public Class Form1

      Dim excel As New Microsoft.Office.Interop.Excel.Application
      
      Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
          excel.Visible = True
      
      End Sub
      

      End Class

      And excel application opens fine and becomes visible when Form1 loads. If you put excel.visible in your form load event as a test does that work?

      Dave Who am I?: http://www.bebo.com/daveauld/

      L 1 Reply Last reply
      0
      • D DaveAuld

        I tried the following;

        Imports Microsoft.Office.Interop.Excel

        Public Class Form1

        Dim excel As New Microsoft.Office.Interop.Excel.Application
        
        Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
            excel.Visible = True
        
        End Sub
        

        End Class

        And excel application opens fine and becomes visible when Form1 loads. If you put excel.visible in your form load event as a test does that work?

        Dave Who am I?: http://www.bebo.com/daveauld/

        L Offline
        L Offline
        Like2Byte
        wrote on last edited by
        #3

        Ah, I see what we did. We were trying to invoke methods on the vars without being inside a form-method. (I'm not a VB.NET developer. Can you tell!?) :P Thank you very much for your help!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups