none
Error while using xlContinuous VBA RRS feed

  • Question

  • Hello Everyone,

    Am getting the following error while using " .Borders.LineStyle = xlContinuous". This works fine in all system except mine

    Error Msg:

    Run-time error '1004'.

    Unable to set the lineStyle property of the border class

    Code:

      With CORE_GetRangeRef2(ws, ProjectView_Starting_Row, 1, LastRow, ColID - 1)
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlBottom
            .Borders.LineStyle = xlContinuous
            .Font.Name = "Arial"
            .Font.Size = "8"
            .Interior.Color = RGB(217, 217, 217)
        End With

    Monday, July 25, 2016 12:02 PM

Answers

  • Yes, i have done repair/reinstall still its not working.

    Am using, Version 14.0.7140.5002(32-bit)- in this version its not working in all system

    the same code works in other version, 14.0.7145.5000(32-bit).


    Hi SReva,

    It seems this issue did not exist in later version of Office. Is your Office Click-To-Run or msi version? I suggest you try to install later Office updates.

    Best Regards,

    Edward

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, July 27, 2016 6:03 AM

All replies

  • This works fine in all system except mine

    In this case it depends on the file, resp. the contents, maybe the other code in the file.

    If you need further help please upload your file (maybe with anonymous data) on an online file hoster like www.dropbox.com and post the download link here.

    A macro to anonymize data in selected cells can be downloaded here:
    https://dl.dropboxusercontent.com/u/35239054/modAnonymize.bas

    Andreas.

    Monday, July 25, 2016 12:49 PM
  • "All systems except mine"? Can you elaborate please?

    Best regards, George

    Monday, July 25, 2016 3:42 PM
  • Hi,

     

    Since we don’t know what CORE_GetRangeRef2(ws, ProjectView_Starting_Row, 1, LastRow, ColID - 1) represents, we couldn't reproduce your issue, please share more information about your code.

    Besides, I can succeed in running the following.

     

    Sub test()

    Dim CORE_GetRangeRef2 As Range

    Set CORE_GetRangeRef2 = ActiveSheet.Range("A1:B5")

    With CORE_GetRangeRef2

            .HorizontalAlignment = xlLeft

            .VerticalAlignment = xlBottom

            .Borders.LineStyle = xlContinuous

            .Font.Name = "Arial"

            .Font.Size = "8"

            .Interior.Color = RGB(217, 217, 217)

        End With

    End Sub

     

    >>This works fine in all system except mine

    Do you mean that others can succeed in using the same file and whole code?

    As what Andreas said, the performance of an application depends on many respects such as the

    operation environment, personal settings, the specific document etc.

    If you could offer more codes and the information about the file content, we may provide useful help.


    Tuesday, July 26, 2016 6:06 AM
    Moderator
  • Hi,

    Yes this file is a common one and its working fine in all system.

    The same ".Borders.LineStyle = xlContinuous" works without any error, when i manually record a macro and execute.

    The problem comes only when using other xls with macro.

    Here is the exact code:

    With ws

            With .Range(.Cells(1, 1), .Cells(Row - 1, 5)) ' this case its fail
                .Borders(1).LineStyle = xlContinuous
                .Borders(2).LineStyle = xlContinuous
                .Borders(3).LineStyle = xlContinuous
                .Borders(4).LineStyle = xlContinuous
            End With
            With .Range(.Cells(1, 1), .Cells(4, Col - 1)) ' this case its fail
                .Borders(1).LineStyle = xlContinuous
                .Borders(2).LineStyle = xlContinuous
                .Borders(3).LineStyle = xlContinuous
                .Borders(4).LineStyle = xlContinuous
            End With
            
            For i = 5 To Row - 1 " here it works
                With .Range(.Cells(i, 1), .Cells(i, Col - 1))
                    .Borders(4).LineStyle = xlContinuous
                End With
            Next i

    End With

    The same code with same data works in all system, same version also

    Tuesday, July 26, 2016 6:29 AM
  • Hi SReva,

    >> The same ".Borders.LineStyle = xlContinuous" works without any error, when i manually record a macro and execute.

    Did you record and execute macro for the same worksheet and same range which file did not work? If you copy one excel file from other computer which works correctly, will it work in the non-worked computer? If you copy the non-worked file to other computer, will it work?

    Based on your description, the recorded code works, I assume it might be related with the specific range, it would be helpful if you could share us the excel file which could reproduce your issue.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, July 26, 2016 7:48 AM
  • Yes, copied file executed in other all systems.
    Tuesday, July 26, 2016 7:58 AM
  • Hi Edward,

    I have tried reproducing the same error in other system.

    But it works in all system.

    Tuesday, July 26, 2016 8:00 AM
  • Hi SReva,

    Did you record and execute macro for the same worksheet and same range which file did not work in the non-worked computer? Since I am not able to test with your file. For a general suggestion, I suggest you repair/reinstall your Office for a try.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, July 26, 2016 9:39 AM
  • Yes, i have done repair/reinstall still its not working.

    Am using, Version 14.0.7140.5002(32-bit)- in this version its not working in all system

    the same code works in other version, 14.0.7145.5000(32-bit).

    Tuesday, July 26, 2016 11:47 AM
  • Yes, i have done repair/reinstall still its not working.

    Am using, Version 14.0.7140.5002(32-bit)- in this version its not working in all system

    the same code works in other version, 14.0.7145.5000(32-bit).


    Hi SReva,

    It seems this issue did not exist in later version of Office. Is your Office Click-To-Run or msi version? I suggest you try to install later Office updates.

    Best Regards,

    Edward

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, July 27, 2016 6:03 AM