Add-Ins for Mac Office 2004

M

Michael Seydl

Hi!

I'm trying to find information on how to create add-ins for mac office 2004,
but haven't found anything yet.

Any hints where to look?

Best Regards,
 
J

JE McGimpsey

Michael Seydl said:
Hi!

I'm trying to find information on how to create add-ins for mac office 2004,
but haven't found anything yet.

Any hints where to look?

You can create VBA-based add-ins using the built-in Visual Basic Editor.
For XL, save the workbook containing your code as an add-in. For Word,
save the document containing your code as a Template.
 
M

Michael Seydl

Thx for your response!

I'm more looking for a kind of sdk because i'd like to create a add-in that
can intercept "open-document"-events and scan the document for particular
fonts. Optinal it should be also possible to replace fonts in certain areas
of text.

thx again,
 
E

Elliott Roper

Michael Seydl said:
Thx for your response!

I think you can do that too. You make the template a global template
and stick it in the Office startup items folder.
 
J

JE McGimpsey

Michael Seydl said:
I'm more looking for a kind of sdk because i'd like to create a add-in that
can intercept "open-document"-events and scan the document for particular
fonts. Optinal it should be also possible to replace fonts in certain areas
of text.

Easily done with VBA:

Create a new document with the code below and save it as a template.
Store the template in the Startup folder. Restart Word. Open a saved
document - the CheckFonts routine will be called by AutoNew, which is
triggered by the _DocumentChange event. Modify to suit.

Put this in a regular code module (Insert/Module):

Dim clsFontCheck As CDocChange

Public Sub AutoExec()
Set clsFontCheck = New CDocChange
Debug.Print "Test"
End Sub


Public Sub CheckFonts()
Const csFoundFonts As String = _
"Found these fonts: "
Dim st As Style
Dim vCheckFonts As Variant
Dim i As Long
Dim sFontsInUse As String

vCheckFonts = Array("Arial", "Times", "Lucida Grande")
For i = LBound(vCheckFonts) To UBound(vCheckFonts)
For Each st In ActiveDocument.Styles
If st.InUse Then
If st.Font.Name = vCheckFonts(i) Then
sFontsInUse = ", " & vCheckFonts(i)
Exit For
End If
End If
Next st
Next i
If Len(sFontsInUse) > 0 Then _
MsgBox csFoundFonts & Mid(sFontsInUse, 3)
End Sub

Put this in a new Class Module named CDocChange

Public WithEvents oApp As Application

Private Sub Class_Initialize()
Set oApp = Application
End Sub

Private Sub oApp_DocumentChange()
'Generic Document Change macro
Dim nOpenDocs As Long
Static nOldOpenDocs As Long

On Error GoTo ErrorHandler
nOpenDocs = oApp.Documents.Count
Select Case nOpenDocs - nOldOpenDocs
Case Is > 0
If oApp.ActiveDocument.Path = vbNullString Then
AutoNew
Else
AutoOpen
End If
Case Is < 0
AutoClose
Case Else
DocChangedFocus
End Select
nOldOpenDocs = nOpenDocs
ResumeHere:
Exit Sub
ErrorHandler:
Debug.Print "oApp_DocumentChange:", Err.Number, Err.Description
Resume ResumeHere
End Sub

Private Sub AutoNew()
End Sub

Private Sub AutoOpen()
CheckFonts
End Sub

Private Sub AutoClose()
End Sub

Private Sub DocChangedFocus()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top