473,625 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fix object error when creating border in excel spreadsheet

20 New Member
I am trying to create borders in an excel spreadsheet programaticaly using VBA. I am getting an object error on line 2 Selection.Borde rs(xlDiagonalDo wn...


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 2199
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Try giving actual values, instead of constants:

Selection.Borde rs(5).LineStyle = -4142
Selection.Borde rs(6).LineStyle = -4142

Regards
Veena
May 22 '10 #2
MarkBStewart
20 New Member
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
7018
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 am getting excel9.olb class id not found. How to register this excel9.olb library. Thanks in advance.
2
1815
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 = New Excel.Application() I wish to keep my application hidden, and thus I use
3
8876
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 know how to build a Keys for this method in C# and how to pass this arguments in this method. Any example howto use this method would be nice. Thanks, Bart
3
1597
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 once a while after runing the program. Anyone know what's the peoblem? Thankx. -- Message posted via http://www.dotnetmonster.com
3
6418
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 & 11. If I use 11, then then all references to Excel fail. If I use 5, the next step in the example fails: Excel.Application oXL = new Excel.Application() ; //fails I can do this:
4
4356
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 Is Nothing Then oExcel = Nothing
4
1760
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. The app also has a OLEDB connection to the same file to fetch data from the file and display it on a datagrid. Now my trouble is that, when I release the COM object, it gets released from smoothly, to say, but the process is still running and...
0
3033
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 cells in the object based on there new values. How do I do this? I've done this before with VBA scripts in excel using the cell.Interior.ColorIndex property, but it definitely doesn't work with this object. Any help would be much appreciated. I've...
3
7164
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 application creates an Excel file (MyTestFile.XLS) just fine per the code submitted here. This code closes the Excel file created and close the Excel application, leaving the Access app open. Then I close Access. After Access is closed, I go to the task...
1
1375
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: objExcel.Workbooks.Open(Page.MapPath("reports\BLCost.xls")) could be the culprit since the Open method returns a reference to a Workbook object that you haven't assigned a variable to. Since you have no variable to explicitly use to destroy the...
0
8251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.