[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

font count

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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
Course of the Month20 days, 2 hours left to enroll

873 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