CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Newyork
    Posts
    50

    Option Strict ON !?!?

    Need help understanding the error.

    Dim xL as Excel.Application

    xL.Sheets("General").activate() --> Error here telling "Option Strict disallows late binding"

    what am i doing wrong ?

    Thanks in advance
    Sihi

  2. #2
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: Option Strict ON !?!?

    try this

    ' this xlapp.workbooks(1).worksheets("General") returns a reference to an Object and not a reference to a worksheet.

    Dim xlwork As Excel.Worksheet

    ' This line explicitly tells the compiler that you're going to cast xlapp.workbooks(1).worksheets as a excel.worksheet and as such
    it should return a reference on a worksheet instead of an object

    xlwork = ctype(xlapp.Workbooks(1).Worksheets("GENERAL"),excel.worksheet)
    xlwork.activate()
    Last edited by Boumxyz2; August 3rd, 2005 at 02:18 PM.
    Nicolas Bohemier

  3. #3
    Join Date
    May 2003
    Location
    Newyork
    Posts
    50

    Re: Option Strict ON !?!?

    Thanks guru, it works

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

Featured