Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

font count

Posted on 2012-03-20
5
Medium Priority
?
237 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses

618 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