PDA

View Full Version : Displaying autotext result on a form



kiwiora
03-04-2012, 06:03 PM
Hi,

I have a template where the user adds their autotext code in the addressauto field and on tabbing out of the field, the result is displayed in the address field.

My original (working) code in 2003 is:

Private Sub AddressAuto_Exit(ByVal Cancel As MSForms.ReturnBoolean)

With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
"C:\Program Files\Microsoft Office\office14\startup\Glossary.dot"
End With

On Error Resume Next
ActiveDocument.AttachedTemplate.AutoTextEntries(AddressAuto)
AddressAuto = ""
End Sub

The macro was falling over at the "attached template" line so I replaced it with (yes I did rename it as autotext.dotx, not glossary.dot)

Private Sub AddressAuto_Exit(ByVal Cancel As MSForms.ReturnBoolean)

With ActiveDocument
.UpdateStylesOnOpen = False
AddIns("C:\Program Files\Microsoft Office\Office14\STARTUP\Autotext.dotx"). _
Installed = True
End With

On Error Resume Next
ActiveDocument.AttachedTemplate.AutoTextEntries(AddressAuto)
AddressAuto = ""
End Sub

Which is great, but I cannot get the result to display in the address field. I have tried:
wtf = "C:\Program Files\Microsoft Office\Office14\STARTUP\Autotext.dotx"
Address = AddIns(wtf).Name(AddressAuto)
Address = ActiveDocument.AttachedTemplate.AutoTextEntries(AddressAuto)
Address = ActiveDocument.AttachedTemplate.wtf(AddressAuto) wtf is further up putting the address of the template
Address = ActiveDocument.AttachedTemplate.BuildingBlocks(AddressAuto)

I understand that this is most likely because the attached template is infact not auotext.dotx, but given that I can't attach it, I am trying to see if there's another way of displaying the autotext result in my form.

Thanks in advance
I am a complete novice.