Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Go Back  Xtreme Visual Basic Talk > > > Excel - setting cell colors, font, omit gridlines


Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2004, 03:27 PM
snufse's Avatar
snufse snufse is offline
Centurion
 
Join Date: Jul 2003
Location: West Palm Beach FL
Posts: 180
Default Excel - setting cell colors, font, omit gridlines


I am importing data from Oracle into Excel.

I need to define cells with certain color distinction and font. Also need to remove grid lines.

Searching the forum for previous similar questions I have not found anything that can point me in right direction.

Thanks.
Reply With Quote
  #2  
Old 06-16-2004, 05:24 PM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

The best way to get a handle on this sort of thing is to open up Excel itself and turn on the Maro Recorder, via Alt|Tools|RecordMacro... Once the recorder is on, you would then make the changes in font and color, etc, as needed and then Stop the recorder. Then open up the VBE with ALT+F11 and then see what code was produced.

But as some examples of what you are looking for:
Code:
Dim oExcel As New Excel.Application Dim oWB as Excel.Workbook oWB = oExcel.Workbooks.Add With oWB.Worksheets(1).Range("A1") With .Font .Name = "Times New Roman" .FontStyle = "Bold" .Size = 10 End With With .Interior .ColorIndex = 3 .Pattern = xlSolid End With End With
Gridlines is a tad trickier. It's a Window setting, so you could use:
Code:
oExcel.ActiveWindow.DisplayGridlines = False
This will turn it off fore the ActiveSheet (within the ActiveWindow).

-- Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #3  
Old 06-17-2004, 08:19 AM
snufse's Avatar
snufse snufse is offline
Centurion
 
Join Date: Jul 2003
Location: West Palm Beach FL
Posts: 180
Default Excel - property setting

Quote:
Originally Posted by Mike_R
The best way to get a handle on this sort of thing is to open up Excel itself and turn on the Maro Recorder, via Alt|Tools|RecordMacro... Once the recorder is on, you would then make the changes in font and color, etc, as needed and then Stop the recorder. Then open up the VBE with ALT+F11 and then see what code was produced.

But as some examples of what you are looking for:
Code:
Dim oExcel As New Excel.Application Dim oWB as Excel.Workbook oWB = oExcel.Workbooks.Add With oWB.Worksheets(1).Range("A1") With .Font .Name = "Times New Roman" .FontStyle = "Bold" .Size = 10 End With With .Interior .ColorIndex = 3 .Pattern = xlSolid End With End With
Gridlines is a tad trickier. It's a Window setting, so you could use:
Code:
oExcel.ActiveWindow.DisplayGridlines = False
This will turn it off fore the ActiveSheet (within the ActiveWindow).

-- Mike

Mike: This really helped. Thank you. I still cannot get the underline to work.

Here is the recorded macro: Selection.Font.Underline = xlUnderlineStyleSingle

Here is my code:

With xlSheet2.Range("A3,B3,C3,D3,E3,F3,G3,H3,I3,J3,K3")
With .Font
.Underline = "xlUnderlineStyleSingle"
End With
End With

Thanks again.
Reply With Quote
  #4  
Old 06-17-2004, 08:26 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Glad it helped!

If you use the Macro recorder, you'll see that the code it generates is
Code:
.Underline = xlUnderlineStyleSingle
That is, no quotes ("). xlUnderlineStyleSingle is a defined constant, with a value of 2.

You need to have your Excel Object Library included within your References for this to work. But if you are using Late Binding, then you would not have any such Reference loaded, and would instead need to define the Constant yourself. Something like this:
Code:
Const xlUnderlineStyleSingle = 2
And then you'll be good to go!

,
Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
 
Excel - setting cell colors, font, omit gridlines
Excel - setting cell colors, font, omit gridlines
 
-->