PDA

View Full Version : Auto/Prefill Macro wont run on 'show' or 'initialize' of userform text-boxes.



AAtkins
07-10-2019, 05:42 PM
Hi there,

I have a userform with several text-boxes. These text-boxes are linked to custom property fields that I have set up in a word doc. I have an action button with working code to allow these text-boxes to fill with the values sitting in the custom fields. I want to have this sub run automatically when the userform opens.
If I can get the textboxes to prefill on userform opening, I would then make the mentioned action button an update/refresh button.

24569

This is what I think should work for running auto filling the text-boxes on start up. 'DocumentPropertyFieldValues' is the name of the userform.

Public Sub showDialogueBox_Click()


DocumentPropertyFieldValues.Show


DisciplineInput.Text = ActiveDocument.CustomDocumentProperties("DisciplineField").Value

'Code repeats for the other fields until
End Sub



This is the code for running it with an action button on the usedform which works.

Private Sub PrefillDetails_Click()
DisciplineInput.Text = ActiveDocument.CustomDocumentProperties("DisciplineField").Value

'other fields and then
end sub

AAtkins
07-10-2019, 07:16 PM
Solved. New macro to call up form, and include name of the userform in each relevant line of the code. duh. haha