Solved

Broders in Excel

Posted on 1998-08-18
9
161 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 103
VB6 / DAO 3.6 / run time error: Couldn't find installable ISAM 7 79
VBA Shell can't Find Word document 11 77
VB6 ListBox Question 4 34
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

25 Experts available now in Live!

Get 1:1 Help Now