Results 1 to 2 of 2

Thread: Code from VBA is working, but from VS2013 no

  1. #1

    Thread Starter
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    167

    Code from VBA is working, but from VS2013 no

    This my working piece of code in VBA

    Code:
    Dim objExcel As Object
            Dim objCell As Object
            Dim objWorksheet As Object
    
            Set objExcel = Excel.Application ' GetObject(, "Excel.Application")
            Set objWorksheet = objExcel.ActiveWindow.ActiveSheet
    
            
                Set objCell = objExcel.ActiveCell
                If objExcel.CountA(objWorksheet.Rows(1).EntireRow) <> 0 Then
                    objExcel.ActiveWindow.SmallScroll Down:=1
                End If
    All works fine. But in vs2013 error occurred
    System.Runtime.InteropServices.COMException was unhandled
    my code is:
    Code:
    Dim objExcel As Object
            Dim objCell As Object
            Dim objWorksheet As Object
    
            objExcel = GetObject(, "Excel.Application")
            objWorksheet = objExcel.ActiveWindow.ActiveSheet
    
                objCell = objExcel.ActiveCell
                If objExcel.CountA(objCell.Rows.EntireRow) <> 0 Then    '<========= ERROR LINE
                    objExcel.ActiveWindow.SmallScroll(Down:=1)
                End If
    Ten Years After - 01 You Give Me Loving

  2. #2

    Thread Starter
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    167

    Re: Code from VBA is working, but from VS2013 no

    .EntireRow is not supporting.
    Can solve by replacing this code:
    If objExcel.CountA(objCell.Rows.EntireRow) <> 0 Then
    to
    If objExcel.CountA(objWorksheet.Rows(objCell.Row)) <> 0 Then
    Ten Years After - 01 You Give Me Loving

Tags for this Thread

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