Solved

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

Posted on 2014-03-10
2
570 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
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…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now