Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Checking if a font is installed (2007)

I have been using the attached function to determine if a specific
font is installed. It seems to work fine is I have my macro security
set at "Enable all Macros" but when I set the macro security to
"Disable all macros with notification" I get an error at For i=0 to
Fontlist.listcount - 1 when I am prompted and allow macros to run.


Runtime error '-2147467259 (80004005): Method 'ListCount of object
_commandbarcombox failed ...

This always ran fine in 2003.

Function FontIsInstalled(sFont) As Boolean
' Returns True if sFont is installed
FontIsInstalled = False
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
If FontList.List(i + 1) = sFont Then
FontIsInstalled = True
On Error Resume Next
TempBar.Delete
Exit Function
End If
Next i

' Delete temp CommandBar if it exists
On Error Resume Next
TempBar.Delete
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Checking if a font is installed (2007)

It works for me in xl2007.
Try declaring your variables.
The 1728 control can be either a CommandBarControl or a CommandBarComboBox.
You are also missing a line continuation character after "Set FontList ="

You may also want to try resetting the Toolbar...
Application.CommandBars("Formatting").Reset
--
Jim Cone
Portland, Oregon USA
http://tinyurl.com/TrialVersions
(commercial excel programs)





wrote in message
...
I have been using the attached function to determine if a specific
font is installed. It seems to work fine is I have my macro security
set at "Enable all Macros" but when I set the macro security to
"Disable all macros with notification" I get an error at For i=0 to
Fontlist.listcount - 1 when I am prompted and allow macros to run.


Runtime error '-2147467259 (80004005): Method 'ListCount of object
_commandbarcombox failed ...

This always ran fine in 2003.

Function FontIsInstalled(sFont) As Boolean
' Returns True if sFont is installed
FontIsInstalled = False
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
If FontList.List(i + 1) = sFont Then
FontIsInstalled = True
On Error Resume Next
TempBar.Delete
Exit Function
End If
Next i

' Delete temp CommandBar if it exists
On Error Resume Next
TempBar.Delete
End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Checking if a font is installed (2007)

I have this executing as part of a workbook open event. It errors when
macros are disabled and prompted but not when they are enabled without
prompting. I will try some of your suggestions but I don't see why in
one case I get the error but not in the other.


On Jan 5, 4:43*pm, "Jim Cone" wrote:
It works for me in xl2007.
Try declaring your variables.
The 1728 control can be either a CommandBarControl or a CommandBarComboBox.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Checking if a font is installed (2007)

On Error Resume Next
Set FontList =
Application.CommandBars("Formatting").FindControl( ID:=1728)

Seems to resolve the problem - I guess possibly since maybe the
formatting commandbar is not loaded for some reason when the fontlist
is trying to be set to it.


On Jan 5, 10:40*pm, wrote:
I have this executing as part of a workbook open event. It errors when
macros are disabled and prompted but not when they are enabled without
prompting. I will try some of your suggestions but I don't see why in
one case I get the error but not in the other.

On Jan 5, 4:43*pm, "Jim Cone" wrote:



It works for me in xl2007.
Try declaring your variables.
The 1728 control can be either a CommandBarControl or a CommandBarComboBox.
You are also missing a line continuation character after "Set FontList ="


You may also want to try resetting the Toolbar...
Application.CommandBars("Formatting").Reset
--
Jim Cone
Portland, Oregon USAhttp://tinyurl.com/TrialVersions
(commercial excel programs)



wrote in ...


I have been using the attached function to determine if a specific
font is installed. It seems to work fine is I have my macro security
set at "Enable all Macros" but when I set the macro security to
"Disable all macros with notification" I get an error at For i=0 to
Fontlist.listcount - 1 when I am prompted and allow macros to run.


Runtime error '-2147467259 (80004005): Method 'ListCount of object
_commandbarcombox failed ...


This always ran fine in 2003.


Function FontIsInstalled(sFont) As Boolean
' * Returns True if sFont is installed
* *FontIsInstalled = False
* *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
* * * *If FontList.List(i + 1) = sFont Then
* * * * * *FontIsInstalled = True
* * * * * *On Error Resume Next
* * * * * *TempBar.Delete
* * * * * *Exit Function
* * * *End If
* *Next i


' * Delete temp CommandBar if it exists
* *On Error Resume Next
* *TempBar.Delete
End Function- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installed Microsoft Office 2007 Ultimate Eddy Excel Discussion (Misc queries) 2 December 20th 09 04:53 PM
I just installed Office 2007 and an Ad-In I have is not working. Ed Excel Programming 4 October 10th 08 02:03 PM
Subscript error in 2007 when testing if Addin is installed XP Excel Programming 5 May 1st 08 06:28 PM
o -t does anyone see and speed increase after office 2007 sp1 is installed? Gary Keramidas Excel Programming 6 December 20th 07 02:00 PM
Detect if font installed- Hiding column kirkm[_6_] Excel Programming 3 September 26th 06 09:30 AM


All times are GMT +1. The time now is 05:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"