turn on Excel gridlines from Access

M

Mo

I posted a similar question a few days ago and got part way to where I need
to be. I still need to know how to get the gridlines in Excel 97 turned on
from Access 97 using VBA. The suggested code received back in my post is
setting up boarders for 1 row. I have tried different things to get all rows
turned on but I have not yet been successful. Here's the suggested code from
my last post. Any hints as to how I can turn on all boarders/gridlines would
be awesome. Also, if anyone knows the significance of 7 to 11 that would be
helpful as well. Thanks

For iLine = 7 To 11
With XL.Application.Range("A1:AU1").Borders(iLine)
.LineStyle = 1
.Weight = 2
.ColorIndex = -4105
End With
Next
 
M

Mo

I just figured out (sort of) the significance of 7 to 11. It seems to have
to do with the direction of lines being drawn. I changed the range to
Range("A1:IV100") and I changed the "7 to 11" to "7 to 13". I get 100 rows
that look like what I'm after, however when I do print preview it looks like
all 100 rows would print not just the # of rows actually populated. I think
what I'm really after is a way to do the equivalent of these Excel manual
steps in Access VBA.

File|Page Setup
select the sheet tab
checkmark Gridlines

If I do these manual steps in Excel then print preview only displays the
rows of the worksheet that are actually populated. Any assistance would be
very much appreciated. Thanks.
 
J

John Nurick

File|Page Setup
select the sheet tab
checkmark Gridlines

Record an Excel macro while you do that. Then strip out all the
unnecessary code from the recorded macro, leaving the one or two
statements that actually do the job. Finally, paste this residue into
your Excel code and adjust it for its new environment.
 
M

Mo

It works! It works! THANKS!

John Nurick said:
Record an Excel macro while you do that. Then strip out all the
unnecessary code from the recorded macro, leaving the one or two
statements that actually do the job. Finally, paste this residue into
your Excel code and adjust it for its new environment.
 
Top