Hi everyone,
I'm getting error when running the following vbscript that formats an Excel sheet. It complains that object doesn't support the property "Selection.Borders".
Is the code for adding borders correct? -
Dim objXL
-
Dim boolXL
-
Dim objActiveWkb
-
Dim filePath
-
-
filePath = "C:\Test.xls"
-
-
Set objXL = CreateObject("Excel.Application")
-
-
objXL.Application.Workbooks.Open (filePath)
-
Set objActiveWkb = objXL.Application.ActiveWorkbook
-
objActiveWkb.Application.DisplayAlerts = False
-
-
With objXL
-
.Range("A1:H1").Select
-
.Selection.Interior.ColorIndex = 15
-
End With
-
-
With objXL
-
.Selection.Borders(xlEdgeRight)
-
.LineStyle = xlContinuous
-
.Weight = xlThin
-
.ColorIndex = xlAutomatic
-
End With
-
-
With objXL
-
.Sheets("Tabelle 1").Select
-
.Columns.AutoFit
-
End With
-
-
objActiveWkb.Save
-
6 1857
Hi everyone,
I'm getting error when running the following vbscript that formats an Excel sheet. It complains that object doesn't support the property "Selection.Borders".
Is the code for adding borders correct?
Try doing it like this: -
With objXL.Selection.Borders(xlEdgeRight)
-
.LineStyle = xlContinuous
-
.Weight = xlThin
-
.ColorIndex = xlAutomatic
-
End With
-
HTH
kadghar, I tried it but still got an "unknown runtime error" on the same line where Borders property is used.
kadghar, I tried it but still got an "unknown runtime error" on the same line where Borders property is used.
Just curious:
are you using excels VBA??
Because if you're not, any other version of VB, even any VBA outside Excel, wont recognize the excel's constants such as xlContinuous, etc..
I'm running the code above as a .vbs script so I guess I am using it outside Excel vba. So what's the alternative? running the code in an Excel macro?
I'm running the code above as a .vbs script so I guess I am using it outside Excel vba. So what's the alternative? running the code in an Excel macro?
well, no, every constant has its own numeric value, just debug the code in an excel's macro. (with F8 instead of F5) and while you're debugging it (while the yellow line is somewhere), you can pass the mouse over every constant, and check its numeric value, for example, instead of xlDown, you can use -4121. If you replace every constant with the numeric value, the issue will be solved.
Thanks kadghar, will try it out.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Allison Bailey |
last post by:
Hi Folks,
I'm a brand new Python programmer, so please point me in the right
direction if this is not the best forum for this question....
I would like to open an existing MS Excel spreadsheet...
|
by: Otie |
last post by:
I found the following under the GetObject help notes and in the
example for GetObject:
"This example uses the GetObject function to get a reference to a
specific Microsoft Excel worksheet...
|
by: Matthew Wieder |
last post by:
I have the following requirements:
Build a stand-alone C# application that asks the user to click in a cell
in an Excel spreadsheet, and then displays the address of that cell in
the C#...
|
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the...
|
by: Howard Kaikow |
last post by:
There's a significant problem in automating Excel from VB .NET.
Reminds me of a problem I encountered almost 3 years ago that was caused by
the Norton Auntie Virus Office plug-in.
Can anybody...
|
by: Anthony |
last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't
really changed since the days of VB6.
That is, I'd do something similar to this
Code:
Dim ExcelApp As...
|
by: Alain \Mbuna\ |
last post by:
Hi everybody.
In my program I have some data that is calculated after some input from the
user. I have written some code that opens an Excel workbook, with 5
worksheets and the calculated data...
|
by: alexia.bee |
last post by:
Hi all,
In some weird reason, excel instance won;t die if i remove the comment
from 4 lines of setting values into struct.
here is a snipcode
public...
|
by: Doug Glancy |
last post by:
I got the following code from Francesco Balena's site, for disposing of Com
objects:
Sub SetNothing(Of T)(ByRef obj As T)
' Dispose of the object if possible
If obj IsNot Nothing AndAlso...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
| |