L
larrysulky
Hi! I have a Word (2003) template that, among other things, maps
typefaces from nice fancy ones to roughly equivalent plain everyday
ones, according to weight, roman/italic, and relative size.
Ideally I would set up a hash table (associative array), but to my
knowledge VBA doesn't have such a concept. So instead I have a
function, which can be called by whatever routine needs it, to look up
the mapping via a Select statement and return an array (see below).
I'm trying to put the mapping data into a side file somehow so that I
don't have to modify the main template all the time with new mappings,
and it would be great if it could be set up such that a non-techie
could maintain the table.
My questions:
1) Am I wrong about the lack of a hash table capability in VBA?
2) Is there a more clever way than setting up a public function that
returns an array?
3) If the public function idea is okay, is there some way I can either:
(a) put it into a separate template, but still call it and return an
array from it (I know how to call a _subroutine_ in this situation, but
not how to call a _function_ and return an array value); or
(b) put the mapping data in a _non-techie-user-editable format_ in a
side file, read it in, and parse it (though this would seem to require
a hash table, or a lot of I/O to read values only when needed)
I would really appreciate any feedback. Thanks
--larry
''''''''''''''''''''''''''''''''''''
Public Function getMappedFont(ByVal FontName As String) As Variant
' _Must_ be Variant to return array.
Dim myMapping(3) As Variant
Select Case UCase(FontName)
Case "SANS-SERIF"
myMapping(0) = "Arial"
myMapping(1) = False
myMapping(2) = False
myMapping(3) = "+0"
Case "SERIF"
myMapping(0) = "Times New Roman"
myMapping(1) = False
myMapping(2) = False
myMapping(3) = "+0"
Case "ACASLON-BOLD"
myMapping(0) = "Times New Roman"
myMapping(1) = True
myMapping(2) = False
myMapping(3) = "+1"
' ... and a hundred more like this ...
Case Else
myMapping(0) = "Times New Roman"
myMapping(1) = False
myMapping(2) = False
myMapping(3) = "+0"
missingFontMapMsgs = missingFontMapMsgs & vbCrLf & FontName
' Append to a global string
End Select
getMappedFont = myMapping ' Assigns an array to the return variable.
End Sub
typefaces from nice fancy ones to roughly equivalent plain everyday
ones, according to weight, roman/italic, and relative size.
Ideally I would set up a hash table (associative array), but to my
knowledge VBA doesn't have such a concept. So instead I have a
function, which can be called by whatever routine needs it, to look up
the mapping via a Select statement and return an array (see below).
I'm trying to put the mapping data into a side file somehow so that I
don't have to modify the main template all the time with new mappings,
and it would be great if it could be set up such that a non-techie
could maintain the table.
My questions:
1) Am I wrong about the lack of a hash table capability in VBA?
2) Is there a more clever way than setting up a public function that
returns an array?
3) If the public function idea is okay, is there some way I can either:
(a) put it into a separate template, but still call it and return an
array from it (I know how to call a _subroutine_ in this situation, but
not how to call a _function_ and return an array value); or
(b) put the mapping data in a _non-techie-user-editable format_ in a
side file, read it in, and parse it (though this would seem to require
a hash table, or a lot of I/O to read values only when needed)
I would really appreciate any feedback. Thanks
--larry
''''''''''''''''''''''''''''''''''''
Public Function getMappedFont(ByVal FontName As String) As Variant
' _Must_ be Variant to return array.
Dim myMapping(3) As Variant
Select Case UCase(FontName)
Case "SANS-SERIF"
myMapping(0) = "Arial"
myMapping(1) = False
myMapping(2) = False
myMapping(3) = "+0"
Case "SERIF"
myMapping(0) = "Times New Roman"
myMapping(1) = False
myMapping(2) = False
myMapping(3) = "+0"
Case "ACASLON-BOLD"
myMapping(0) = "Times New Roman"
myMapping(1) = True
myMapping(2) = False
myMapping(3) = "+1"
' ... and a hundred more like this ...
Case Else
myMapping(0) = "Times New Roman"
myMapping(1) = False
myMapping(2) = False
myMapping(3) = "+0"
missingFontMapMsgs = missingFontMapMsgs & vbCrLf & FontName
' Append to a global string
End Select
getMappedFont = myMapping ' Assigns an array to the return variable.
End Sub