Access VBA to add borders to excel cells

The_Captain_Slog

New Member
Joined
Sep 23, 2009
Messages
9
HI

I am trying to add borders to cells in an excel worksheet programmaticlly from access vba

I can manage to open excel load my data from tables/queries into the worksheet, close save etc

what i cant do is update the borders it says that .borders(xledgetop) is invalid


colours formatting etc i can do but this is really annoying me now

any help appreciated
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Are you using early binding or late binding? If you are setting a reference and declaring

Dim appXL As Excel.Application

then it is early binding.

If it is

Dim appXL As Object

Then it is late binding.


If you are using late binding then you have to supply the values for any constants. But here's what it would be for early binding:
Code:
    With .Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
    With .Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
    With .Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With
    With .Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlMedium
    End With

It needs to be tied to the Application object.
 
Upvote 0
cheers Bob

I was using late binding -- but had not added all the needed references to excel -- which didnt help lol

it seems to be working now
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,102
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top