Solved

VB.net Excel Add-n Using Font Dialog to format a  cell

Posted on 2014-03-10
2
579 Views
Last Modified: 2014-03-10
Hi/ I am using FontDialog to capture information about an Excel cell that I will be using later.
How do I actually format the cell using this information.
I tried  Globals.ThisAddIn.Application.ActiveCell.Font = FontDialog1.Font
but get an error saying that the font is ReadOnly


                Dim FontName As String = FontDialog1.Font.Name
                Dim FontStyle As String = FontDialog1.Font.Style.ToString
                Dim FontSize As String = FontDialog1.Font.Size.ToString
                Dim FontColorARGB As String = Me.FontDialog1.Color.A & ";" _
                                          & Me.FontDialog1.Color.R & ";" & _
                                          Me.FontDialog1.Color.G & ";" & _
                                          Me.FontDialog1.Color.B
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 39917505
You can't just assign a Font object - you have to set each of the properties you want individually:
With Globals.ThisAddIn.Application.ActiveCell.Font
.Name = FontName
 .FontStyle = FontStyle
                .Size = CLng(FontSize)
 .Color = RGB(Me.FontDialog1.Color.R, Me.FontDialog1.Color.G ,Me.FontDialog1.Color.B)
End With

Open in new window


or something along those lines.
0
 

Author Closing Comment

by:murbro
ID: 39917754
Thanks very much
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question