Formating Excel Cells from VB.net

Friends,

I am wanting to format a series of cells with a the font style of "Times New Roman"

I did this code, and it compiles, but it doesn't change the font style as desired.

        With oSheet.Range("A1", "N1")
            .Font.Bold = True
            .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter
            .Font.Italic = True
            .Font.Size = 12
            .Cells.WrapText = True
            .Font.FontStyle = "Times New Roman" '<--- Does NOT change font to Times New Roman.

        End With

Also, I want another set of cells to be set as currency, with negative values in Red and in ( )'s?

        With oSheet.Range("E3", "T" & NumberOfCarsInRace + 2)

            .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter
            .Font.Italic = False
            .Font.Size = 8
            .Style = "Currency" '<---- This sets it to currency, but not with the option of having negative values in red and with ( )'s around the value
 
       End With

Thanks!
indy500fanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PockyMasterCommented:
You are trying to set the fontStyle, which in my memory only is an enumeration of Bold, Italic and that kind of stuff
0
PockyMasterCommented:
If you want to create a new font you can use:
Dim myNewFont as  new Font ("Times New Roman", 12 )

.Font = myNewFont
0
indy500fanAuthor Commented:
PockyMaster,

Can you implement your suggestion with my existing code snippet.  As it is now, it is giving the error: 'New' cannot be used on an interface.

Also any suggestions for the currency part of my question?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

PockyMasterCommented:
With oSheet.Range("A1", "N1")
            .Font.Bold = True
            .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter
            .Font.Italic = True
            .Font.Size = 12
            .Cells.WrapText = True
            .Font.Name = "Times New Roman"   '<-- this should work (worked on my machine :D)
        End With
and let me think about the currency part (never done that, but can have a look for you)
0
PockyMasterCommented:
You might find the following link useful, regarding the number style:
http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/NumberFormat.html
0
indy500fanAuthor Commented:
PockyMaster,

Thanks for the help with the font.Name, but I'm still having trouble with the currency setting

According to the website you gave,

I should be able to say:

        With oSheet.Range("E3", "T" & NumberOfCarsInRace + 2)
            .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter
            .Font.Italic = False
            .Font.Size = 8
            .Style.Number = 8 <--The program breaks and exits here!!!

        End With
0
Bob LearnedCommented:
If you are looking for Currency format, then:
   .Style = "Currency"

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
indy500fanAuthor Commented:
Bob,

I'm so embarrassed.  I forgot all about this one...

I am so sorry.

Best Regards,
Eric
0
PockyMasterCommented:
Uh, you're welcome ...
0
indy500fanAuthor Commented:
PockyMaster,

Doh! I forgot you helped me with the first part!  I should have split the points!  Can I fix that?
0
PockyMasterCommented:
It's ok :D
0
indy500fanAuthor Commented:
That's not funny :)

I'd just hate to tick you off and lose your help in the future.  You have been most helpful in the past and I am grateful of you help.
0
PockyMasterCommented:
Well, you didnt, it's ok...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.