Results 1 to 4 of 4

Thread: error inconsistency

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2010
    Posts
    132

    Question error inconsistency

    im not understanding why some of the code below works fine and some gives an error

    These work fine
    .PageSetup
    .Borders
    .Range

    These give error "Option strict on disallows late binding"
    .Cells
    .Rows
    .Columns

    what is the difference???

    example...
    Code:
        dim oExcel As Excel.Application
        dim oBook As Excel.Workbook
        dim oSheet As Excel.Worksheet
    
    With oSheet
    
    'WORKING FINE
    .PageSetup.Zoom = 65
    
    .Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
    
    .Range("A27").Value = "Hello"
    
    
    
    'GIVING ERROR
    .Cells(1, 1).value = "Hello"
    
    .Rows("60:60").Font.Bold = True
    
    .Columns("A:Z").ColumnWidth = 8.0
    
    End With

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: error inconsistency

    you need to cast those erroneous lines to the correct datatype

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: error inconsistency

    vb Code:
    1. Imports excel = Microsoft.Office.Interop.Excel
    2.  
    3. Public Class Form1
    4.  
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Dim oExcel As excel.Application
    7.         Dim oBook As excel.Workbook
    8.         Dim oSheet As excel.Worksheet
    9.  
    10.         With oSheet
    11.  
    12.             'WORKING FINE
    13.             .PageSetup.Zoom = 65
    14.             'borders isn't a member of excel.Worksheet
    15.             .Borders(Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous
    16.             .Range("A27").Value = "Hello"
    17.  
    18.  
    19.  
    20.             'GIVING ERROR
    21.             'value isn't a member of excel.Worksheet.Cells
    22.             .Cells(1, 1).value = "Hello"
    23.             'Font isn't a member of excel.Worksheet.Rows
    24.             .Rows("60:60").Font.Bold = True
    25.             'ColumnWidth isn't a member of excel.Worksheet.Columns
    26.             .Columns("A:Z").ColumnWidth = 8.0
    27.  
    28.         End With
    29.     End Sub
    30. End Class

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2010
    Posts
    132

    Resolved Re: error inconsistency

    oops sorry for the late reply.. i think it may be way too much to go through all the code and try to fix everything to make it work... thanks for the info though

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