G'day "Robert L" <address923@hotmail.com>,
Alt+F9 to reveal field codes.
Steve Hudson - Word Heretic
steve from wordheretic.com (Email replies require payment)
Without prejudice
Robert L reckoned:
>Hi All,
>
[quoted text clipped - 6 lines]
>Regards,
>Robert
hi Robert,
Try the following, which I picked up somewhere:
Sub FieldCodeToString()
Dim Fieldstring As String, NewString As String, CurrChar As String
Dim CurrSetting As Boolean, fcDisplay As Object
Dim MyData As DataObject, X As Integer
NewString = ""
Set fcDisplay = ActiveWindow.View
Application.ScreenUpdating = False
CurrSetting = fcDisplay.ShowFieldCodes
If CurrSetting <> True Then fcDisplay.ShowFieldCodes = True
Fieldstring = Selection.Text
For X = 1 To Len(Fieldstring)
CurrChar = Mid(Fieldstring, X, 1)
Select Case CurrChar
Case Chr(19)
CurrChar = "{"
Case Chr(21)
CurrChar = "}"
Case Else
End Select
NewString = NewString + CurrChar
Next X
Set MyData = New DataObject
MyData.SetText NewString
MyData.PutInClipboard
fcDisplay.ShowFieldCodes = CurrSetting
End Sub
Select the field then run the code. The code puts the field's coding into
the clipboard, from where you can paste it into whatever application you
want.
Cheers
PS: You'll need to include a vba reference to the Microsoft Forms 2.0 (or
later) object library.
> Hi All,
>
[quoted text clipped - 6 lines]
> Regards,
> Robert
Jay Freedman - 14 Dec 2004 04:34 GMT
>hi Robert,
>
>Try the following, which I picked up somewhere:
>
>Sub FieldCodeToString()
All that is fine if Robert's "equation" is an EQ field (although even
then the field code doesn't look much like the printed equation). If
it's an Equation Editor object, all he'll get from the macro is the
string "EMBED Equation 3".
AFAIK, there's no way to extract the text of the equation from an
Equation Editor object. Maybe Bob Mathews of Design Science will drop
in to let us know whether MathType has an interface to VBA that can do
it.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Robert L - 14 Dec 2004 07:36 GMT
Hi,
thank you all three for your replies. But unfortunatelly the macropod's code
returns only "EMBED Equation 3", just like Jay supposed :) So it seems there
is no way for me to make my macro do this. It's a pity because the macro
extracts texts from pictures fine, but because of this, part of the job will
have to be done manually :(
Anyway, I thank you all three for your replies very much (and macropod for
the code. I will use it in some other macros:).
Best regards,
Robert
macropod - 14 Dec 2004 08:21 GMT
Hi Robert,
For future reference, a possible workaround is to insert your equations as
EQ fields, instead of via the Equation Editor. You can get much the same
result, in terms of appearance but, instead of a bitmap, you get a real
text-based field that will sit in-line with other text by default. EQ fields
will adopt whatever style/formatting you apply to the rest of the paragraph
(unless you add a Charformat switch). Plus, you can edit them!
Cheers
> Hi,
>
[quoted text clipped - 8 lines]
> Best regards,
> Robert
Robert L - 14 Dec 2004 09:31 GMT
Hi macropod,
Unfortunately, the Word documents that I run my macro on are created by
people in another company. So I cannot influence this. But the equations
appear in the docs rarely, so it should not be a big problem to retype texts
from equation(s) to another document manually.
Thank you very much once more.
Regards,
Robert