Extract AutoText Values beyond 255

  • Thread starter Thread starter olimu
  • Start date Start date
O

olimu

I wrote some code to extract AutoText contents from the Normal.dot but
the value property of the AutoTextEntries only returns the first 255
characters.

Public Sub AutoTextEntries_Export()
'
' Code for exporting AutoText in Normal.dot
' written 10.11.2006 by Olivier Muff
'
Dim i As AutoTextEntry

Open "MyAutoTextEntries.txt" For Output Shared As #1
For Each i In NormalTemplate.AutoTextEntries
Write #1, i.Name & "¦" & i.Value
Next i
Close #1

End Sub

Any suggestions on how to get around this limit?

mhillig1 asked a similar question on Feb 16 2005 which Suzanne S.
Barnhill said she responded to "Please see my reply to your duplicate
question earlier or elsewhere. " but I cannot find her post. Does
anyone have it?

Thank you,
Olivier Muff
Zürich
 
That is, for reasons I can't begin to guess, "as designed". The VBA
help topic for the Value property as it applies to the AutoTextEntry
object says explicitly:

"For AutoCorrectEntry and AutoTextEntry objects, the Value property
only returns the first 255 characters of the object's value. Setting
the Value property to a string longer than 255 characters generates an
error."

To retrieve more than that, you have to use the Insert method of the
AutoTextEntry object to put the entry into a Range in a scratch
document somewhere. You can then either save the document as a plain
text file, or write the Range's .Text property to a file as you're
doing now.

For demo code that does handle very long AutoText entries as well as
graphics and formatted entries, download the AutoTextDumper template
from http://jay-freedman.info.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
Great pointers Jay!

The AT dumper works well. It even extracts images. Now I just need to
move the extract with formating into a SAPscript table.

Thanks for the help,
Olivier
 

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

Back
Top