Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Set Excel Border Through VB

how to make border cell in excel to be no border via VB?
i use this syntax

oSheet.Range("A1").BorderAround ColorIndex:=5, Weight:=xlThick
but can't figure it out how to make it no border


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Create Border In Excel Using VB
Please help me.....
I want to create Border in Excel but i use Visual Basic 6.0

Create Border In Excel
does anybody know how to create border in excel using VB6?


Excel Border Not Working In Vb6??
Hi all

Why i cant set border to the excel sheet from VB6 application? I useing fallowing lines and all works except borders.


excel_sheet = excel_app.activesheet
With excel_sheet.Cells(5, 1).offset(0, 2)
.FormulaR1C1 = "=SUM(R[-" & ylemine & "]C[0]:R[-1]C[0])"
.NumberFormat = "# ### ##0.00"
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlMedium
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
.Borders(xlEdgeBottom).Weight = xlThin
End With

I try this way ot but nothing is hapening


With excel_sheet
.Range("A5:P10").Borders(xlEdgeLeft).LineStyle = xlContinuous
.Range("A5:P10").Borders(xlEdgeLeft).Weight = xlThin
.Range("A5:P10").Borders(xlEdgeLeft).ColorIndex = xlAutomatic
.Range("A5:P10").Borders(xlEdgeTop).LineStyle = xlContinuous
.Range("A5:P10").Borders(xlEdgeTop).Weight = xlThin
End With

I think this is so simple but i dont see this solution.

FillColor And Border Help In Excel
Trying to fill a color (yellow) and set a border (bottom) on the first row in an excel sheet from a vbscript. I don't get any errormessages with the fill color, but neither does the color appear. With the borders I get the errormessage "unknown runtime error"...can someone help?


Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

With objExcel

'------ FillColor ------
With objExcel.Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

'------ Set Borders ------
.Selection.Borders(xlDiagonalDown).LineStyle = xlNone '<--- error message "unknown runtime error"
.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
.Selection.Borders(xlEdgeLeft).LineStyle = xlNone
.Selection.Borders(xlEdgeTop).LineStyle = xlNone
With objexcel.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.Selection.Borders(xlEdgeRight).LineStyle = xlNone
.Selection.Borders(xlInsideVertical).LineStyle = xlNone

end with

Excel/PowerPoint Border Problem..
hey guys....i am pasting a link into power point which contains a cell from excel... the cell has objects in it, such as arrows... when i paste into excel the cell border shows up in powerpoint. and i can't simply fill the cell in with white, because i have a background setup in power point... and i am unable to just copy the object because power point won't let you paste a link with just an object, it has to be linked to cells...any ideas???

something else i just noticed.... when i first paste the link into power point the border does NOT show up....however, when the cell is updated (arrows change directions, shapes change) and power point is updated with the new cell info, thats when the stupid border shows up!!

Adding Border To Excel And Locking The Sheet
Hi I'm building a small application in access that produce a report in excel and I have 3 things left that I don't know how to code properly.Thank you for your help.

Dim ApExcel As Object
Set ApExcel = CreateObject("Excel.application")

'first thing that doesn't work

With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
End With

'secong thing that doesn't work

With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
End With

'third thing that doesn't work

apexcel.ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowSorting:=True

How Can I Change The Border Color Of A Textbox (fixed Border) ?
Dear Friends,

How can I change the border color of a textbox instead of black color (fixed border) ? Same as in "New Post Thread" title textbox?

Thanks in advance.


How To Simuilate Moving Border When Copying A Cell Using A Grid, Like Excel Does.
I'm using VSFlexGrid, and I have an option to copy and paste cells, I want to simulate what excel does, when choosing copy in excel it creates a moving border around the do I do that in VB?.....the grid does not support that....HELP

No Border
I need to make the bored = 0
no bored but I still need to be able to move the form and to be able when minimized to get down, not to the right...
can it be done?

Is there a way to make the border of a form be the colors that YOU want? Or a bitmap? Or something else to what it is?

ok i got a circle moveing and im trying to make it when it hits a line then it stops... I have gotten it to were it hits it it will stop but then i have to keep in mind the line is only so long so i want to be able to still go around the line to the left or right here is my code

If Shape1.Top = (Line7.Y1 - 120) And (Shape1.Left) < (Line7.X1) Or (Shape1.Left) > (Line7.X2) Then
Shape1.Top = Shape1.Top + 120
Text1.Text = 0
please help me this is really starting to confuse me

No Border
How can I make it so there is not the bar at the top of the form with the
-[]X (minimize, maximize, exit) buttons and still have a menu such as File and Help?

How do i make the border on my form invisible.? i set the borderstyle to none, and the border became invisible, but like a week after, the border is back, and i can't make it invisible anymore.

How do i make the border on my form invisible.? i set the borderstyle to none, and the border became invisible, but like a week after, the border is back, and i can't make it invisible anymore.

Ok Im Creating A Program That Has *No* Border Whats So Ever Im Studying Codes On How To Can Drag My Form And Stuff With Out The Border But WHen I Try The Code On My Form It Wont Work!

So Can Ya Help Me On How To Make My Non-Border Program Move??

Grid Border

I'm using grid to display a text file, so that each letter is in one column. This way I can select text blocks..

The problem is that it doesn't look good since there is a boder between each two columns which causes some space between letters that makes the display look bad..

Is there a way were the text can be written on the border, like in excel.. Or any other solution that could make it look better.. ? (my main goal is to be able to select blocks of text)

Thanks in advance..

Get Rid Of Forms Border
hi i have the forms border property set to none but all of a sudden it seems to have reappeard and i cannot take it off it only started when i created a menu ( its an invisible menu used only as a pop up menu) any ideas why thsi is?

Get Rid Of Forms Border
I've made the same experience as this thread ...

However, the sample given on uses the VB menu editor to define menus. In my experience, this already makes the border appear. You don't have to display any of the menus. In other words, even if you use the menu editor only for a popup menu, your form will have borders.

It would be interesting if the menu editor output could also be created by hand! In that case, we may find a way around the problem.

Any ideas?

Add Border To Image

I want to add a white border to a scanned image. I know I could just open the image in a paint program, add the borders, save and be done. It seems an easy enough task but I have a load of files and would like to create some sort of command line tool. You know, C:addborder.exe *.tif or something like that. I guess it doesn't have to be command line just so long as it reads a directory.

I am using vb6 and have only limited experience with graphics. I did manage to make a raw/bmp converter but I am by no means confident in what I'm doing. I'm working wtih grayscale scanned images so they could be tif, bmp, or jpg (most of the common formats) so any tips or links would be most helpful.

Thank you.

Border Styles
Heres a question I need solved. What if one of your main forms is using a border style of fixed single(1) When running the application and you press the close icon at the top right, how do you get it to end the process as currently it seems to hide the application but not end the process

Much help would be appreciated.

How To Set Page Border?
Hi guys,
Can anyone tell me on how to set the page border?I have a few tables in a word document.I set my table border to false but i need to set the page border as a frame for those tables.
Thanks for helping.
Urgent coz project come to dead line already.

oi ching

Form Border
I had a borderless form, and since adding a popup menu to it, the form now has a border again. I want the form to be borderless, and have set the BorderStyle to 0-None. Any ideas on how to get no border even though I have a menu?

Listbox Border
Is there any way to remove the listbox border completely, or make it transparent? I can't get rid of its black outline. Thanks

Frame Border
Is there any way to get a non-square border around a frame. I would like a frame which is almost a square but with kind of rounded edges.

Menus Without A Border?

I am making an application that uses pop up menus. (Pop them up by right clicking on the form). However, I want to make those menus with a Borderstyle = 0.

Is this not possible? Is there NO way to make pop up menus without having a border?

Please help


TextBox Border
Is it possible to change the border color of a TextBox. Is there an API call that allows that.

PS: I cannot use a container under my textbox.


Form Border
I want to give a standard form a border style like the one used on a splash form. I'm new to this part of vb so I could use some help.

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = (-16)
Const WS_BORDER = &H800000

Private Sub Form_Load()

Dim Style As Long

Style = GetWindowLong(hwnd, GWL_STYLE)
SetWindowLong Me.hwnd, GWL_STYLE, Style Or WS_BORDER

No Border On WebBrowser?
How do you make the WebBrowser function not have a border around it?

Webbrowser Border ?
is there anyway to disable webbrowser border like setting label border=0?

best regards

Form Border
Quote:Originally Posted by OnErr0rThe WS_THICKFRAME style will give it the 3D look. WS_SYSMENU is included to make the icon show in the taskbar.

Dim lStyle As Long
lStyle = GetWindowLong(hwnd, GWL_STYLE) Or WS_SYSMENU Or WS_THICKFRAME
SetWindowLong hwnd, GWL_STYLE, lStyle
SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_FRAMECHANGED ' draw the frame style

What api or declared Function did you used in order to be able to use above statements ?


HELP!! Border Widths
I have been attempting to solve this problem for some time and have not yet come across a solution
I use the following code to create a border around a user control

'save the border width
OldWidth = UserControl.DrawWidth
UserControl.DrawWidth = 1
'set the co-ordinates
X1 = 0
X2 = UserControl.ScaleWidth
Y1 = 0
Y2 = UserControl.ScaleHeight
'Draw a line. (B)=state that co-oridinates include oposite corners, (F)=fill the box
Line (X1, Y1)-(X2, Y2), vbBlue, B
'restore the original border width
UserControl.DrawWidth = OldWidth
What happens here is that the top and left borders are created but the right and bottom ones do not appear. Why??? I want to be able to create flat borders around the user control and be able to change the width YET have the borders the same width all around. If someone can sort this I would be eternally grateful!!

Border Style
Ok, one more silly question...

I just want to have a fixed form, but with the minimize and close buttons.

I must be blind, but I can't find the info in MSDN.

"Never trust a computer you can't throw out a window." Steve Wozniak [img]images/icons/wink.gif[/img]

Border On Forms
When I make a shortcut-menu on my borderless form, visual basic automatically converts the border attribute to "fixed dialog" instead of "none".

How do I get around that

Forms With No Border
hey again evryone. i have created a customized skined form and i want to be able to have a menu on it. I have tooled at some cool programs and they have the menu inside a coolbar. i have tried using a mnu when the form is borderless but it does not work. i know about pop up menus but i want the proper one. is there anything i can do to make a menu on a borderless form?

thanks allot

Border Style
I want to chage the border style of my form by pressing a button i tried a few things but it didnt work like
form1.BorderStyle = 0
form1.BorderStyle 0
form1.BorderStyle none
things like that but i cant figure it out.

Thin Border
Is it possible to force a thin border on text boxes, dropdown lists, etc.? I think that's what I've seen it called before. Anyway, the control is only about half as deep as normal.

Form Border
hi, just wandering if its posible to have a form without a heading and control box, not be sizable, but still have the border around the form (ie using a xp manifest on vb, so having the blue border around the form but without any control box). thanks

Form Border
Upon the clicking of a button, I'm trying to make a form become maximized and lose it's border. This is the code I have:

Form1.WindowState = 2
Form1.BorderStyle = 0

The maximizing works fine, but the form retains it's border. There's no error messages or anything, it just keeps the same border.

Form Border
If i set a forms borderstyle to None then it gives me this ugly flat box. How to I make that form have a None borderstyle and also look 3D?,

Flexgrid Border
hey i was just wondering if there was a way to create a coloured border around a cell in the flexgrid i know this would involve subclassing the control to do it and also the use of the WM_PAINT ... if anyone an idea how to do this it would be greatly appreciated.

Border Styles
I use the following code (from to set the border style of a user control. The code works great, I was wondering if anyone knows the constants for other border styles.

''## Border Styles
Private Const GWL_EXSTYLE As Long = (-20)
Private Const GWL_STYLE As Long = (-16)
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOSIZE As Long = &H1
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_NOACTIVATE As Long = &H10
Private Const SWP_FRAMECHANGED As Long = &H20 ' The frame changed: send WM_NCCALCSIZE
Private Const SWP_NOOWNERZORDER As Long = &H200 ' Don't do owner Z ordering

Private Const WS_EX_CLIENTEDGE As Long = &H200
Private Const WS_EX_STATICEDGE As Long = &H20000

Public Property Let Appearance(ByVal New_Appearance As AppearanceConstants)
Dim lStyle As Long

menmAppearance = New_Appearance
lStyle = GetWindowLong(UserControl.hwnd, GWL_EXSTYLE) 'Retrieve current style

Select Case New_Appearance 'Toggle style flags
Case [Flat]: lStyle = lStyle And Not WS_EX_CLIENTEDGE And Not _
Case [3D]: lStyle = lStyle Or WS_EX_CLIENTEDGE And Not WS_EX_STATICEDGE
Case [Thin]: lStyle = lStyle And Not WS_EX_CLIENTEDGE Or WS_EX_STATICEDGE
End Select

SetWindowLong UserControl.hwnd, GWL_EXSTYLE, lStyle 'Apply changes
SetWindowPos UserControl.hwnd, 0, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOZORDER Or _
PropertyChanged "Appearance"
End Property

API Draw Border ?!!
have anyone noticed the borders of the msn tray alert that rolls up near the system tray as u recieve a new email ?
i need to draw that border around a picture box
what is the suitable api ???

Raised 3D Border?
I'm interested in finding a way to show a raised borderstyle for some standard controls. I know I could create a User control that does what I want but I could but help noticing that the VBA forms controls have the capability.

Would there be a sendmessage API command to do this sort of thing or is that just something built into VBA form controls but not standard VB6?

Kicking the idea around some. Not much in results so far. Anyone else familiar with the thought?


ListBox Border
this is driving me insaine, how can i remove the black border from a listbox control?

Border Color
As far as I know there's no such thing as a BorderColor property for labels. Is there actually any way to have labels with, say, red borders?

No Border, But Still In Task Bar
I want my app to have no border, but still show up in the task bar. How can I do this?

Selection Border
when you click on a butten there comes a kind of border, with dots, on the button... is it posible to NOT get that border when you click on a button?
(in other words, that you cant see that that button is selected... i hop you know what i mean!)

(srry my english is bad... i know:P)

Custom Border
How can I customise the border of a form so it doesnt use the default settings of the OS being used?

Aswell as the title bar. Or to not have the title bar but still the border.

Make A Border Appear
In windows, when I open a folder and set its view properties to thumbnails and you click any of the thumbs it makes a blue border appear round the selected thumb.

Ok, I have a project in vb6 that also shows thumbnails in a list view. When I click a thumbnail I want a border to appear. I have been trying for ages but cant figure out how to do it??

Can anyone help me out?

Copyright 2005-08, All rights reserved