Solved

Broders in Excel

Posted on 1998-08-18
9
164 Views
Last Modified: 2010-04-30
How do I set the borders in Excel(Office 95)?

I was trying the following code but just couldn't get it working.

ExcelApp.ActiveWorkbook.ActiveSheet.Range("C13:I13").Borders(xlBottom).LineStyle = xlDot
    ExcelApp.ActiveWorkbook.ActiveSheet.Range("C13:I13").Borders(xlTop).Weight = xlThin

Error message is : 1004 : Border method of Range class failed.

Please help. Thanks.
0
Comment
Question by:terencebeh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1429701
The easiest way is to record a macro.  Tools, macro, record macro.  Then go to tools, macro, select the macro and then select edit.  There is your code you can add to it from there.  This is the prefered way to design macros in excel.


Specialist
0
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1429702
After you do this, you copy the code to the visual basic module after you select the appropriate object (get object, openworkbook, ect)(but thats pretty obvious)


Good luck
0
 
LVL 1

Author Comment

by:terencebeh
ID: 1429703
That's exactly what I did. But it doesn't work.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:electrick
ID: 1429704
Here is code from a project I have that works, the Excel object
I created is named InvForm

InvForm.Application.Cells(x + 19, 6).Value = cTotal
InvForm.Application.Cells(x + 19, 6).BorderAround _
Weight:=xlThin, ColorIndex:=xlAutomatic

Also, I had used the same method that SPECIALIST mentioned,
that's the easiest way I know of finding out how to do something.
I'd give him the points.

0
 

Expert Comment

by:nightrage
ID: 1429705
.Worksheets(1).Range("J2").Borders.LineStyle = xlContinuous
Worksheets(1).Range("J2").Borders.ColorIndex = xlAutomatic

it should be something like that
0
 
LVL 1

Author Comment

by:terencebeh
ID: 1429706
That's what exactly I do. I am suspecting that the version of
Microsoft Excel 5.0 Object Library file is the cause of this.
Can some of you check the date/size of this file : xl5en32.olb?

0
 

Expert Comment

by:electrick
ID: 1429707
Are you using
ExcelApp.ActiveWorkbook.ActiveSheet.Range("C13:I13").BorderAround...? or
ExcelApp.ActiveWorkbook.ActiveSheet.Range("C13:I13").Borders...?
Borders collection only has properties.
you need to use the .BorderAround Method
0
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1429708
TERENCEBEH,

I guess I should mention, depending on what method you are using to do this, you may or may not have to modify the code.  For example, It depends on whether you use the getobject, open workbook etc.  If you use  Workbooks.Open filename:="nameandpath", you should be able to post the code without modification.

If you use Getobject, you may have to modify certain aspects of the code.

Let me know, post your full code if this doesn't help.

SPECIALIST




0
 

Accepted Solution

by:
brewer earned 30 total points
ID: 1429709
Hi!

I actually copied your code and tried running it but an error message was echoed.

I tried removing ExcelApp and it worked.

Why don't you try it. I hope this will help you.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question