Using Excel 2002 with VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mitchell Vincent

    #1

    Using Excel 2002 with VB.NET

    Will this work if someone has office 2002 installed? :

    Dim oExcel As Object
    Dim wbk As Object
    Dim a As String

    Try
    oExcel = CreateObject("E xcel.Applicatio n")
    Catch ex As Exception
    MessageBox.Show ("Microsoft Office not installed, or the version
    installed is too old.", "Microsoft Office Error",
    MessageBoxButto ns.OK, MessageBoxIcon. Error)
    Exit Sub
    End Try

    wbk = oExcel.Workbook s.Open(Filename :=TheExcelFile, UpdateLinks:=Fa lse,
    ReadOnly:=True)

    Is that an example of "late binding" ?

    --
    - Mitchell Vincent
    - kBilling - Invoices Made Easy!
    - http://www.k-billing.com
  • ng

    #2
    Re: Using Excel 2002 with VB.NET

    That looks right. Do you have someone to try it out for you?

    Tom

    Mitchell Vincent wrote:
    [color=blue]
    > Will this work if someone has office 2002 installed? :
    >
    > Dim oExcel As Object
    > Dim wbk As Object
    > Dim a As String
    >
    > Try
    > oExcel = CreateObject("E xcel.Applicatio n")
    > Catch ex As Exception
    > MessageBox.Show ("Microsoft Office not installed, or the version
    > installed is too old.", "Microsoft Office Error",
    > MessageBoxButto ns.OK, MessageBoxIcon. Error)
    > Exit Sub
    > End Try
    >
    > wbk = oExcel.Workbook s.Open(Filename :=TheExcelFile,
    > UpdateLinks:=Fa lse, ReadOnly:=True)
    >
    > Is that an example of "late binding" ?
    >[/color]

    Comment

    • ng

      #3
      Re: Using Excel 2002 with VB.NET

      That looks right. Do you have someone to try it out for you?

      Tom

      Mitchell Vincent wrote:
      [color=blue]
      > Will this work if someone has office 2002 installed? :
      >
      > Dim oExcel As Object
      > Dim wbk As Object
      > Dim a As String
      >
      > Try
      > oExcel = CreateObject("E xcel.Applicatio n")
      > Catch ex As Exception
      > MessageBox.Show ("Microsoft Office not installed, or the version
      > installed is too old.", "Microsoft Office Error",
      > MessageBoxButto ns.OK, MessageBoxIcon. Error)
      > Exit Sub
      > End Try
      >
      > wbk = oExcel.Workbook s.Open(Filename :=TheExcelFile,
      > UpdateLinks:=Fa lse, ReadOnly:=True)
      >
      > Is that an example of "late binding" ?
      >[/color]

      Comment

      • Peter Huang [MSFT]

        #4
        RE: Using Excel 2002 with VB.NET

        Hi

        Yes, this is a usage of LateBinding.

        The code below will work on excel 2002.
        Dim oExcel As Object
        Dim wbk As Object
        Dim a As String

        Try
        oExcel = CreateObject("E xcel.Applicatio n")
        Catch ex As Exception
        MessageBox.Show ("Microsoft Office not installed, or the version
        installed is too old.", "Microsoft Office Error", MessageBoxButto ns.OK,
        MessageBoxIcon. Error)
        Exit Sub
        End Try
        'I add the two code below to test the code.
        oExcel.Visible = True
        Dim TheExcelFile As String = "c:\test.xl s"
        wbk = oExcel.Workbook s.Open(Filename :=TheExcelFile,
        UpdateLinks:=Fa lse, ReadOnly:=True)


        Best regards,

        Peter Huang
        Microsoft Online Partner Support

        Get Secure! - www.microsoft.com/security
        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        Working...