Solved

Broders in Excel

Posted on 1998-08-18
9
162 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

773 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