Solved

Broders in Excel

Posted on 1998-08-18
9
160 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
  • 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now