Solved

font count

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 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