473,395 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to fix object error when creating border in excel spreadsheet

I am trying to create borders in an excel spreadsheet programaticaly using VBA. I am getting an object error on line 2 Selection.Borders(xlDiagonalDown...


This is my code:

Expand|Select|Wrap|Line Numbers
  1.  xlWS.Range("F2:J410").Select
  2.     Selection.Borders(xlDiagonalDown).LineStyle = xlContinuous
  3.     Selection.Borders(xlDiagonalUp).LineStyle = xlContinuous
  4.     With Selection.Borders(xlEdgeLeft)
  5.         .LineStyle = xlContinuous
  6.         .ColorIndex = 0
  7.     End With
  8.     With Selection.Borders(xlEdgeTop)
  9.         .LineStyle = xlContinuous
  10.         .ColorIndex = 0
  11.     End With
  12.     With Selection.Borders(xlEdgeBottom)
  13.         .LineStyle = xlContinuous
  14.         .ColorIndex = 0
  15.     End With
  16.     With Selection.Borders(xlEdgeRight)
  17.         .LineStyle = xlContinuous
  18.         .ColorIndex = 0
  19.     End With
  20.     With Selection.Borders(xlInsideVertical)
  21.         .LineStyle = xlContinuous
  22.         .ColorIndex = 0
  23.     End With
  24.     With Selection.Borders(xlInsideHorizontal)
  25.         .LineStyle = xlContinuous
  26.         .ColorIndex = 0
  27.     End With
May 22 '10 #1
2 2190
QVeen72
1,445 Expert 1GB
Hi,

Try giving actual values, instead of constants:

Selection.Borders(5).LineStyle = -4142
Selection.Borders(6).LineStyle = -4142

Regards
Veena
May 22 '10 #2
No go. I am still getting "ActiveX Componenet Cannot Create Object" message. Any ideas? Should I somehow be refering to the worksheet object in the Selection statement?
May 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hema S | last post by:
Hi, I want to use excel object in my asp.net application. When excel application is installed its working fine. When i uninstal the excel application and refer the relevant dll explicitly... i...
2
by: Darren Barrick via .NET 247 | last post by:
Hello All! I am using Office Automation in one of my applications in orderto read/write to an excel spreadsheet from a VB.Net application. I thus create the application with ExcelApplication...
3
by: Bart Filipski | last post by:
Hello, Does anyone know how looks the syntax of SORT method in Excel object ( i mean precisely in Excel.Workbook.Worksheet.Cells.Sort(...) ) I have tryied in VBA and it works great, but I don't...
3
by: yaya via DotNetMonster.com | last post by:
Hi all, Im using Microsoft Excel 11.0 Object Library as my program reference to create an Excel object, everything works fine but I notice that a process named EXCEL.EXE will run on the backgraound...
3
by: eye5600 | last post by:
I want to read/write Excel files but I am having trouble getting started. Using MS article 302084 as a cookbook, I try to add the reference for MS Excel Object Library. Two versions are listed, 5 &...
4
by: Norton | last post by:
I type the following code to open/close an excel appz Dim oExcel As Excel.Application oExcel = new Excel.Application .... .... ... If Not oExcel Is Nothing Then oExcel.Quit() If Not oExcel...
4
by: Mr.Doubt | last post by:
I've a widows application, that makes use of an EXCEL COM object, to run a few macros available in a EXCEL file. The object is created when the app is started and is closed when the app is closed....
0
by: NDK | last post by:
Ok so I have an html page with an embedded excel object. I load some information into the object from a spreadsheet. (works perfectly) I would like to be able to change the background of a few...
3
by: rlntemp-gng | last post by:
RE: Access 2003/Excel 2003 Problem: After I close the Access application completely, I go out to the Task Manager and there is an Excel.exe object still sitting out there. My Access...
1
by: Scott M. | last post by:
Many methods return objects when they are called. With Excel these objects are placed in memory and must be destroyed via ReleaseComObject as you have done with your NAR method, but the line: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.