Solved

font count

Posted on 2012-03-20
5
229 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

706 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

21 Experts available now in Live!

Get 1:1 Help Now