#### Attempting to "Embed" a font in Excel 2003 - Could use help with VBA code

Hey there everyone,

I do not know what I missed, but I must have missed something...
The code (below) runs without errors in Excel 2003 on Vista and XP. It
does copy the font into the font folder, but it is not registering
right.

At the CMD I can DIR the fonts folder and see that the file is there,
but if I look using explorer it is not visible (not font name or file
name).

For this upload I changed the location of font file to "C:\temp\". The
actual location of the file is on a network server and is accessed via
UNC.

When this codes works as intended it would copy the font, register the
font, and notify all open applications, including Excel, about the
font.

As far as I can tell, this is about as close as you can get to
embedding a font in Excel, unless you have 2007, which I do not.

Finally, the real work being done here is, with only a few small
changes, taken from code I found online.  I had to change things like
"user" to "user32" and add aliases to make the errors stop.  Without
the "32" it could not find the file, and without the alias it would
say it could not find an entry point.

Mystif

Private colFoundFiles As New Collection
Private strPath As String

Private Declare Function CreateScalableFontResource Lib "gdi32" _
Alias "CreateScalableFontResourceA" (ByVal fHidden As Long, _
ByVal lpszResourceFile As String, ByVal lpszFontFile As String, _
ByVal lpszCurrentPath As String) As Long

Private Declare Function AddFontResource Lib "gdi32" Alias _
"AddFontResourceA" (ByVal lpFileName As String) As Long

Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long

Private Declare Function WriteProfileString Lib "Kernel32" Alias _
"WriteProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String) As Integer

Private Sub Workbook_Open()
IsFontInstalled
End Sub

Sub IsFontInstalled()
Dim lngFileCount As Long

strPath = Environ("SystemRoot") & "\Fonts"

With Application.FileSearch
.NewSearch
.LookIn = strPath
.Filename = "astronbv.ttf"
.SearchSubFolders = False
.FileType = msoFileTypeAllFiles
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) = 0 Then
FileCopy "C:\Temp\astronbv.ttf", strPath & "\astronbv.ttf"
Install_TTF "Astron Boy Video", "astronbv.ttf", _
Environ("SystemRoot") & "\System32"
Else
Exit Sub
End If
End With
End Sub

'  This sub installs a TrueType font and makes it available to
'  all Windows apps. It takes these arguments:
'
'  FontName$is the font's name (e.g. "Goudy Old Style") ' ' FontFileName$ is the font's filename (e.g. "GOUDOS.TTF")
'
'  WinSysDir$is the user's System folder (e.g. ' "C:\WINDOWS\SYSTEM" or "C:\WINDOWS\SYSTEM32") ' ' ** Before calling this sub, your code must copy the font file ' to the user's Fonts folder. ** ' Sub Install_TTF(FontName$, FontFileName$, WinSysDir$)
Dim Ret%, Res&, FontPath$, FontRes$
Const WM_FONTCHANGE = &H1D

FontPath$= Environ("SystemRoot") & "\Fonts\" & FontFileName$
FontRes$= WinSysDir$ & "\" & Left$(FontFileName$, _
Len(FontFileName$) - 3) & "FOT" Ret% = CreateScalableFontResource(0, FontRes$, _
FontFileName$, WinSysDir$)
Ret% = AddFontResource(FontRes$) Res& = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) Ret% = WriteProfileString("fonts", FontName + " " & _ "(TrueType)", FontRes$)
End Sub

 0
none269 (2)
1/13/2008 2:28:45 PM
excel 39879 articles. 2 followers.

0 Replies
645 Views

Similar Articles

[PageSpeed] 38

Similar Artilces:

Embed Excel with form
Is it possible to show an excel spreadsheet within a form? Have it interactive where the user can scroll...? QB On Fri, 28 May 2010 02:58:01 -0700, QB <QB@discussions.microsoft.com> wrote: Yes. You can use the Unbound Object Control to do that. It can be a bit tricky to work with. You can even interact with the Excel object inside using VBA and the Excel object model. -Tom. Microsoft Access MVP >Is it possible to show an excel spreadsheet within a form? Have it >interactive where the user can scroll...? > >QB ...

embedding graphs from excel
Hi I have a bunch of graphs in an excel document. I use them in a lot of different power point presentations. I use the function copy/paste special/paste link. For the most part this seems to work fine. The problem I have is that the excel document is constantly getting updated and as a result the file name changes. This disrupts the link I have created for the graph in the power point document. Can someone suggest how I change the filename and have that change reflected in the power point as well? Thanks. Chris Hello, Maybe a tool like Ezpaste-xl2anywhere...

windows app embed java app
Hi Windows application embed IE control embed applet <--- this is the way i know that emebd a java app into a windows app, but the disadvantage is slow, because applet take a longer time to load than a normal standalone java app. Is there any way to embed a JFrame/Java standalone application(with interface) into a windows app? thanks from Peter (cmk128@hotmail.com) ...

excel 2000 message
excel 2000 message - 'cannot use object linking and embedding' Were they hit by the MSBlast worm? One poster (Lutz Meyer) guessed that this was the cause of his problems. I haven't seen any confirmation/denial, but you may want to read his post: http://groups.google.com/groups?threadm=3F3971AF.FA4490F5%40msn.com Post back with your results. I'm curious if that was the problem. (It's come up quite a few times since MSBlast hit.) bill bootle wrote: > > excel 2000 message - 'cannot use object linking and > embedding' -- Dave Peterson ec35720@msn.c...

How to save an embedded Excel file?
This is a multi-part message in MIME format. ------=_NextPart_000_0040_01C56BA8.412C7EC0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable 21:06 2005-6-7 I received an Excel file, is a chart from a company. Because the Company = logo and address occupied more than half page; and it has "freeze = panes". This file is unable to select, copy or do any amendment. 1. I intend to make some correction update and take away the big logo, = and want to save as Excel Workbook.=20 It says: This workbook contains embedded objects. Microsoft Offi...

Cannot use object linking & embedding error
I tried to open up an excel file in Excel 2000 and i got the following error "Cannot use object linking & embedding error" The computers are networked but the file i am trying to open is on my own computer and is not shared! I also tried to open up another excel file over the network and it gives the same error as well as SVCHOST.exe keeps crashing the computer! This is probably not a lot to go on, but can someone please help me solve this annoying problem thanks Noel I am having the exact same issue. This is happening all across our network. Any help will be greatly ...

Embedding graphics in html emails, how to without coding path to graphic in, pls?
I have a really neat smiley programs that somehow "injects" animated gifs into an html email. So that's great when I'm at home and I want to embed pictures like animated smileys, etc. But at the office I have no such program and am not allowed to install one, of course. How can I do the same thing at the office _without_ having to tamper with the html file to begin with? Is there a way? Hope so, I'd like to be able to attach smileys, etc., without hardcoding them in. It would be too tough to type up the emails in html each time and adding path to gif, etc. Thank yo...

Outlook 2003
Good day, Outlook 2003, Windows XP. My email format is set to RTF. I do not use Word to modify or edit email messages. When creating a new email, I click Insert>Object, choose Create from file, Link, Display as icon. Problem: the icon does not display, only the filename. I choose another icon, no can do. Why is this? Thank you! ...

Embedding Excel on a web page
Can you do it? I want the data in an excel file to be a table in the middle of an HTML doc. Not a copy/paste but a live link to the data. "Steve" <sb6633@sbc.com> wrote in message news:OcmZjIRjDHA.488@TK2MSFTNGP09.phx.gbl... > Can you do it? I want the data in an excel file to be a table in the middle > of an HTML doc. Not a copy/paste but a live link to the data. > File, save as, HTML. The box to allow interactivity is grayed out until you select a single sheet. You can save the whole workbook to html but without interactivity. Then again who is to say you can'...

Embedded movie in PP 2003
Thanks to this discussion group, I can now reliably embed music and other sound tracks. Now, I am trying to embed a movie clip. It is a .wmv file of about one minute. It plays fine, but I want to embed it. Thank you -- Sadly you cannot embed movies in 2003 -- john ATSIGN PPTAlchemy.co.uk Free PPT Hints, Tips and Tutorials http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html "Hickory" wrote: > Thanks to this discussion group, I can now reliably embed music and other > sound tracks. Now, I am trying to embed a movie clip. It is...

After Sending Email Cannot See Embedded Images (Outlook 2003)
Ok...this started happening only recently, and i can't pinpoint why. Am using Outlook 2003. Firstly: When someone sends me an email with an embedded image "I can" see it, no problem. I can create an email with an embedded image, no problem. The recipients can see the images, no problem. I usually copy myself on these emails, no problem. Here's my dilemma: Problem is when I open the email i just sent, i cannot see the embedded image. All i see is an "X". Temporary Solution: Under the "Mail Format" tab in Outlook I have the following settings for: - C...

Embedding Images and/or Word Processor/Text Files in Excel
Is it possible to place a pointer/ref within an XL cell to a specific filename.jpg ? or, to a specific filename.doc or filename.wp ? I would like to be able to click on a cell and have a picture opened with an image viewer, such as Irfanview. Thanks Hi, You can use Hyperlink (CTRL+K or Insert->Hyperlink) to point to a specific filename. Regards, Peter -- http://blog.jausovec.net "Vince" je napisal: > > Is it possible to place a pointer/ref within an XL cell to a specific > filename.jpg ? > or, to a specific filename.doc or filename.wp ? > > &g...

Embedding Email Object in Excel?
I want to either embed or link-to email objects from within a database that I'm building in Excel. These objects currently exist as standard Office (Exchange) emails but I could save them first as rtf or txt files. What I'd like to accomplish is, within the database to see where a change has been logged and then to click on a link (or an icon) and open the email to see the documentation of the reasons behind that change. Can this be done? What's the best way to go about it? Thanks Hi, I noticed nobody had replied to this. I have no spectacular way o doingt his but...

Embed a 'match' statement in sumproduct?
Excel 2007 I'm trying to help a coworker who wants to generate a few summary pieces of data (like a pivot table, but for only a few categories). The raw data includes both valid and invalid product codes, so these summaries need to exclude the rows with invalid codes and their associated data. Sheet1: Location of this formula. Formula is looking for a total for a specific location Sheet2: Raw data including valid and invalid product code sales Sheet3: List of invalid product codes This formula works, but does not exclude the invalid products: =SUMPRODUCT(('Sheet 2...

IE 6 freezing using OWA and messages with embedded graphics
We have a strange problem, hoping someone has seen this or has ideas. Exchange 2003 SP2 clustered back-end (4 active, 1 passive). NLB front end. IE 6 on XP is freezing for about 3-5 minutes on certain messages with embedded graphics, and then they display minus the graphics. IE7 beta works fine. IE6 running on Win2k3 works fine. If we go straight to the back-end server for OWA it works fine. The problem happens with or without SSL. No problem with MAPI clients. It's hard to tell if we are debugging an IE problem or an Exchange problem. Any ideas? -GT ...

Can I embed a clickable link that includes command line arguments?
I 'm familiar with the process of embedding a clickable link to a file located on a share accessible to the recipient, and do so regularly by using a UNC formatted path: \\ServerName\Path\to the \location\of the\file (Interesting ... the "<" ">" I wrapped the above line in dissappeared as soon as I entered the close bracket. In Outlook [plain text] I'm not used to that happening.) My question: is it possible to do the same thing to launch a .exe (or ..cmd) with command line arguments? Something like: \\UNC Path\Executable /argument1 /a...

Embed button in email
Hi Everyone, Is there any possiblity to embed an button in email? so that the receiver of email clicks the button, an acknowledgement email is sent to the sender. Thanks You can also configure read receipt in Outlook. To do this you need to go to: Tools\Options\Preferences\Email Options\Tracking Options and check Read receipt checkbox. "meendar" <askjavaprogrammers@gmail.com> wrote in message news:1144782296.203020.34940@i39g2000cwa.googlegroups.com... > Hi Everyone, > > Is there any possiblity to embed an button in email? so that the > receiver of email...

Escape codes embedded in XML
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2 AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2 AID=\"551228206\"></Tag2></Tag1><Tag1 QID=\"55114\"><Tag2 AID=\"5511406\"></Ta...

Embed Excel Spreadsheet inside an HTML page(IE)
Hi Guys, I'm wondering if its possible to embed an excel spread sheet inside an HTML page. If I open the HTML page I should be able to view the contents of the excel spread sheet and I can make changes directly from the HTML page to the excel sheet and save the changes. Thanks!!!! Hi Kwyjibo, Kwyjibo wrote: > I'm wondering if its possible to embed an excel spread sheet inside > an HTML page. If I open the HTML page I should be able to view the > contents of the excel spread sheet and I can make changes directly > from the HTML page to the excel sheet and save the ch...

How to embed HTML in an Email?
I am using outlook express. How do I embed HTML in an email? You'd get a more expert answer if you posted in a newsgroup that was specific to Outlook Express. OE is part of Internet Explorer, not Microsoft Office which is what this group supports and has expertise in. http://www.microsoft.com/windows/ie/dgbrowser/en-us/default.mspx Choose your version from there. When you post, please include your version of OE and account type (POP3, etc.), as well as any error messages/numbers, and troubleshooting steps you've taken. -- Kathleen Orland - MVP Outlook Outlook Tips: http...

Embed picture in excel mail merge into word?
How do I embed a picture in excel so that it will mail merge into word? "Donna" wrote: > How do I embed a picture in excel so that it will mail merge into word? See MS article, "About mail-merge fields" where it says to create a column in your data base titled "Picture" In every line under that heading type the path/filename of the picture you want printed. If you place a <<Picture>> field in the merge document , it will print the picture. ...

how do I paste linked and embed from worksheet to another workshe.
I am trying to copy and link information i excel that is tabular. There are images at the top of each of the tabs. When I try to copy and link normally I lose the images adn formating. I am able to copy and paste and embed link into a seprate workbook. I have not been able to do this from work sheet to work sheet . I grabed the code that lets me paste into the seperate workbook, but it hangs up when I try to do it in the same workbook. You can copy and paste a linked picture. That should pick up everything you select. Select your data and copy it. Select the destination cell. Pre...

Embed table in Excel Chart
I have inherited a spreadsheet containing a chart. The chart has a "floating" table containing with data from another part of the workbook. When I single-click on the table, the following text is shown in the formula bar... =EMBED("Microsoft Excel Worksheet","") If I double-click on the table the "hidden" table appears. I want to create this same effect in another chart, but I'm puzzled at how to set this up. I know it's possible to create a linked embedded object from excel into word or another application, but how to do this withing...

Embedded Excel file in Word
I have an embedded Excel worksheet in a Word file (2003). In the Word file, there is a table that is linked to the embedded Excel worksheet. If I double-click on the table, it opens Excel and I can make changes. However, if I attempt to do that while Excel is already running, I get a "file not found" from Excel. I need to widely distribute this file and I want to minimize the instructions I will give. This will be distributed to finance people who always have their Excel running. Is there a work around? Thanks I have no problems regardless if excel is open or not, you mi...

embedded font problem
Never miiiiiinnnnnnnnnnnnnnnnd. I went back to an older version of my file and it opened just fine without all the font problems. Might have to do some tweaking to bring it up to speed, but I've got the time ;-) ...