Preview content of AutoText item on a userform

  • Thread starter Kris G via OfficeKB.com
  • Start date
K

Kris G via OfficeKB.com

Is there any way, using standard Office/VBA functionality, I can allow
users to preview the content of a specific AutoText entry on a userform.

What I'm looking for is something similar to the preview-area of the
"AutoText" tag in the AutoCorrect dialogbox.
 
D

Dave

Hi Kris,
I had a similar post not too long ago. Someone was nice enough to provide me
the suggestion similar to the code below. This will preview the 1st 254
characters of the autotext in a 'preview' text box.

Hope this helps.

Private Sub chk1_Change()
' Declare the variables
Dim atEntry1 As AutoTextEntry
Dim AutoTextEntryName As String
' If ck1 is checked then preview the first 254 characters of the Autotext
If chk1.Value = True Then
AutoTextEntryName= Me.txtPreview.Value
Set atEntry1 =
ThisDocument.AttachedTemplate.AutoTextEntries("AutoTextEntryName")
Me.txtPreview.Value = atEntry1.Value
' If chk1 is not checked then set the preview text box to blank
Else: txtPreview.Value = ""
End If
 
K

Kris G via OfficeKB.com

Hi Dave,

Thanks a lot for the reply. I assume that txtPreview refers to a standard
textbox-control? In that case, however, any formatting, tables and graphics
will be ignored by the control.

The builtin dialog "wdDialogEditAutoText" apparantly includes a control
which is capable of showing such formatting.

I am aware that the built-in dialogs cannot be modified. But I was hoping
there was some way of utilizing this fuctionality, either via the
Word/Office object model or maybe via an API?
 
J

Jawaka

One possibility might be to add a Rich TextBox Control to the form and using
the AutoTextEntry.Insert method with the RichText argument set to True.

Unfortunately the additional control, Richtx32.ocx, is a security risk so
you will get a message telling you "the subject is not trusted for the
specified action" when you try to add it to your form.

You can edit the Registry to make it work, but then you are probably more
vulnerable to malicious attacks.
 
Top