Solved

font count

Posted on 2012-03-20
5
234 Views
Last Modified: 2012-06-27
I am trying to pull out a list of fonts into my excel using vba, this code below is not working for me though. it is erroring out in the first for  statement as the fontlist does not return a count.

For i = 0 To Fontlist.ListCount - 1
Cells(i + 1, 1) = Fontlist.List(i + 1)
Next i

Open in new window

0
Comment
Question by:Moizsaif123
[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
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 37744632
What is the object Fontlist, and where is it defined?
0
 
LVL 17

Expert Comment

by:vb_elmar
ID: 37744684
instead ...
Cells(i + 1, 1) = Fontlist.List(i + 1)

it should be ...
Cells(i + 1, 1) = Fontlist.List(i)
0
 
LVL 4

Author Comment

by:Moizsaif123
ID: 37746784
@GrahamSkan

yes forgot to define this in my code, the whole code is now listed below. It lists out all the font names although there is a particular font names "UniverseLight" which does not come in my list of names..Not sure whether this is a name that is included in the Excel 2007 and I use Excel 2003.

The code below points at ID:=1728 which is something I have not digested. Is this Id a known for fonts and how is it a control.


Set FontList = Application.CommandBars("Formatting").FindControl(ID:=1728)
    
'   If Font control is missing, create a temp CommandBar
    If FontList Is Nothing Then
        Set TempBar = Application.CommandBars.Add
        Set FontList = TempBar.Controls.Add(ID:=1728)
    End If

For i = 0 To FontList.ListCount - 1
Cells(i + 1, 1) = FontList.List(i + 1)
Next i

Open in new window

0
 
LVL 4

Author Comment

by:Moizsaif123
ID: 37754252
never mind that, iv seen the id in the watch iv added to the control.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 37754483
Great. I'm glad that you sorted the last bit yourself. It's the best way to learn.

Good luck.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 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