Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 813285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:20:03+00:00 2026-05-15T01:20:03+00:00

I have piece of code which I use to format a range of cells

  • 0

I have piece of code which I use to format a range of cells in Excel. It works fine in Excel 2007 but when the range is only 1 column wide and it is Excel 2003 instead of 2007, I’ll get an error saying the I am assigning invalid value for a border’s line style.

** valuables such as “xlInsideHorizontal”, I have declared them as CONSTANT with the proper values.

Please help.

   procedure formatCells(FRCELLROW, FRCELLCOL, TOCELLROW, TOCELLCOL: Integer;
                         TOPSTYLE, TOPCOLOUR, TOPWEIGHT,
                         BOTTOMSTYLE, BOTTOMCOLOUR, BOTTOMWEIGHT,
                         LEFTSTYLE, LEFTCOLOUR, LEFTWEIGHT,
                         RIGHTSTYLE, RIGHTCOLOUR, RIGHTWEIGHT: Integer;
                         INNERVSTYLE, INNERVCOLOUR, INNERVWEIGHT: Integer;
                         INNERHSTYLE, INNERHCOLOUR, INNERHWEIGHT: Integer;
                         HORIZONTALCELLALIGNMENT: Integer;
                         FontBold: Boolean;
                         NumberFormat: String
                         );
   var
      tmpRange: Variant;
   begin
        tmpRange := eclApp.range[eclApp.Cells[FRCELLROW, FRCELLCOL],
                                 eclApp.Cells[TOCELLROW, TOCELLCOL]];

        tmpRange.Borders[xlEdgeTop].LineStyle := TOPSTYLE;
        if TOPSTYLE <> xlNone then begin
           tmpRange.Borders[xlEdgeTop].ColorIndex := TOPCOLOUR;
           tmpRange.Borders[xlEdgeTop].Weight := TOPWEIGHT;
        end; //if
        tmpRange.Borders[xlEdgeBottom].LineStyle := BOTTOMSTYLE;
        if BOTTOMSTYLE <> xlNone then begin
           tmpRange.Borders[xlEdgeBottom].ColorIndex := BOTTOMCOLOUR;
           tmpRange.Borders[xlEdgeBottom].Weight := BOTTOMWEIGHT;
        end; //if
        tmpRange.Borders[xlEdgeLeft].LineStyle := LEFTSTYLE;
        if LEFTSTYLE <> xlNone then begin
           tmpRange.Borders[xlEdgeLeft].ColorIndex := LEFTCOLOUR;
           tmpRange.Borders[xlEdgeLeft].Weight := LEFTWEIGHT;
        end; //if
        tmpRange.Borders[xlEdgeRight].LineStyle := RIGHTSTYLE;
        if RIGHTSTYLE <> xlNone then begin
           tmpRange.Borders[xlEdgeRight].ColorIndex := RIGHTCOLOUR;
           tmpRange.Borders[xlEdgeRight].Weight := RIGHTWEIGHT;
        end; //if
        tmpRange.Borders[xlInsideVertical].LineStyle := INNERVSTYLE;
        if INNERVSTYLE <> xlNone then begin
           tmpRange.Borders[xlInsideVertical].ColorIndex := INNERVCOLOUR;
           tmpRange.Borders[xlInsideVertical].Weight := INNERVWEIGHT;
        end; //if
        tmpRange.Borders[xlInsideHorizontal].LineStyle := INNERHSTYLE;
        if INNERHSTYLE <> xlNone then begin
           tmpRange.Borders[xlInsideHorizontal].ColorIndex := INNERHCOLOUR;
           tmpRange.Borders[xlInsideHorizontal].Weight := INNERHWEIGHT;
        end; //if
        tmpRange.HorizontalAlignment := HORIZONTALCELLALIGNMENT;
        tmpRange.Font.Bold := FontBold;
        tmpRange.NumberFormat := NumberFormat;
   end; //
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:20:04+00:00Added an answer on May 15, 2026 at 1:20 am

    Likewise, if you have specified a “1” row height, you’d get the same error. Inner styles are for lines between adjacent cells. A “1” column width range have no horizontally adjacent cells, hence no vertical inner lines. Excel 2007 is probably ignoring the invalid value, whereas Excel 2003 is throwing an error.

    Test for the number of columns and number of rows for ranges before passing values to your “formatCells” procedure, and if you encounter a “1” in any of these pass “xlNone” (-4142) in place of “INNERVSTYLE, INNERVCOLOUR, INNERVWEIGHT” or “INNERHSTYLE, INNERHCOLOUR, INNERHWEIGHT”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code which works 90% of the time: $user_details=$fb->api_client->users_getInfo($fb_user, array('last_name','first_name','proxied_email'));
I have a piece of C# code in which I use the goto statement.
I have this piece of code which works, however I would like to change
I have this piece of code which i use to compare a timestamp field
I have the following piece of code which accepts only number form keyboard, function
I have this piece of code which works in Firefox link = $('<a>link</a>'); var
I have a piece of code below which I am trying to use to
I have this piece of code which I use for firing a local notification
I have a piece of code in which I need to use a string
I have this piece of code which check the last customer_id from the db.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.