Discussion:
Export Autotext Enties to a word table
(too old to reply)
Michael Jenkin [SBS-MVP]
2005-12-06 23:08:43 UTC
Permalink
Hello,

I have a client with hundreds of custom autotext entires and they need
them exported to a word file table.

I have written code to do this and it works well. The only problem is
any formatting and images stored in the Autotext are lost.

Here is the code. Any ideas ? Being a novice at VBA, I would suggest the
issue is with Typetext or maybe the way I addressed the selection.

Thanks


Sub ExportAutotextEntries()


Documents.Add


ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=(2),_
NumColumns:=2,DefaultTableBehavior:=wdWord9TableBehavior,_
AutoFitBehavior:=wdAutoFitFixed

For Each i In ActiveDocument.AttachedTemplate.AutoTextEntries

Selection.TypeText i.Name
Selection.MoveRight Unit:=wdCell

Selection.TypeText i.Value
Selection.MoveRight Unit:=wdCell

Next i

MsgBox "Done"

End Sub
--
Regards,

Michael Jenkin
MCP MVP SBS
Australia

www.mickyj.com
Tony Strazzeri
2005-12-06 23:07:57 UTC
Permalink
Hi Michael,

Instead of using I.value define I as AutotextEntry (not essential) and
replace the line with I.Insert Where:=Selection.Range,
RichText:=True


Cheers
TonyS
Michael Jenkin [SBS-MVP]
2005-12-07 01:26:10 UTC
Permalink
Absolutely wonderful.

If anyone else ever needs to do this, take a look at

Sub ExportAutotextEntries()


Documents.Add


ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=(2),
NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:= _
wdAutoFitFixed

For Each I In ActiveDocument.AttachedTemplate.AutoTextEntries


Selection.TypeText I.Name
Selection.MoveRight Unit:=wdCell

I.Insert Where:=Selection.Range, RichText:=True

Selection.MoveRight Unit:=wdCell

Next I

MsgBox "Done"

End Sub


works a treat !
Post by Tony Strazzeri
Hi Michael,
Instead of using I.value define I as AutotextEntry (not essential) and
replace the line with I.Insert Where:=Selection.Range,
RichText:=True
Cheers
TonyS
--
Regards,

Michael Jenkin
MCP MVP SBS
Australia

www.mickyj.com
Charles Kenyon
2005-12-06 23:14:36 UTC
Permalink
Its all been written. Try the add-in at
http://word.mvps.org/FAQs/Customization/ExportAutocorrect.htm.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by Michael Jenkin [SBS-MVP]
Hello,
I have a client with hundreds of custom autotext entires and they need
them exported to a word file table.
I have written code to do this and it works well. The only problem is
any formatting and images stored in the Autotext are lost.
Here is the code. Any ideas ? Being a novice at VBA, I would suggest the
issue is with Typetext or maybe the way I addressed the selection.
Thanks
Sub ExportAutotextEntries()
Documents.Add
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=(2),_
NumColumns:=2,DefaultTableBehavior:=wdWord9TableBehavior,_
AutoFitBehavior:=wdAutoFitFixed
For Each i In ActiveDocument.AttachedTemplate.AutoTextEntries
Selection.TypeText i.Name
Selection.MoveRight Unit:=wdCell
Selection.TypeText i.Value
Selection.MoveRight Unit:=wdCell
Next i
MsgBox "Done"
End Sub
--
Regards,
Michael Jenkin
MCP MVP SBS
Australia
www.mickyj.com
Michael Jenkin [SBS-MVP]
2005-12-06 23:48:54 UTC
Permalink
Thanks, I tried this one yesterday and the results were not quite what I
was after.

Thanks for the response.
Post by Charles Kenyon
http://word.mvps.org/FAQs/Customization/ExportAutocorrect.htm
--
Regards,

Michael Jenkin
MCP MVP SBS
Australia

www.mickyj.com
Loading...