That is essentially how the Microsoft Letter Wizard works. Click on DocProperty under Field names in the pop-up window, and click on Recipient (or whatever you.
Youtube insert form fields in word code#
If the document is protected (using Tools + protect Document), and if the MacroButton foeld is in a protected area of the document, you will need to unprotect the document immediately before the line that starts:Īnd reprotect it immediately after that line - e.g.:ĪctiveDocument.Protect Type:=wdAllowOnlyFormFields, _Īlternatively, if you did want to use a UserForm in an AutoNew macro, and wanted the UserForm to have a button that allowed your users to pick a name from the Outlook Address Book, you could use almost exactly the same code as provided in this article to do that as well. In the Word menu, click on the Insert menu, click the Quick Parts dropdown, and select Fields. If your users experience either of these problems, it is down to an Outlook configuration issue, and you should post the details in the newsgroup. The user may find that the first time they run the macro in each Word session, they might see the "Choose profile" dialog and have to click OK:Īnd/or, they may find that the "Select Names" dialog displayed by the macro doesn't automatically display their contacts, and they have to select the drop-down and select "Contacts" every time. 'Insert the name at the current insertion point StrName = Application.GetAddress(AddressProperties:=strCode, _ 'Insert the modified address at the current insertion point StrAddress = Left(strAddress, Len(strAddress) - 1) StrAddress = Left(strAddress, iDoubleCR - 1) & _ IDoubleCR = InStr(strAddress, vbCr & vbCr) 'Eliminate blank paragraphs by looking for two carriage returns in a row 'If user cancelled out of 'Select Name' dialog, quit
RecentAddressesChoice:=True, UpdateRecentAddresses:= True)
UseAutoText:= False, DisplaySelectDialog:=1, _ Then provide a name for the field in the Bookmark section.
Right-click on the Form Field and select Properties. On the Developer Menu select the Legacy Tools icon which is in the Controls section: On the Legacy Forms menu click the first icon to insert a Form Field. StrAddress = Application.GetAddress(AddressProperties:=strCode, _ Click in your Word document wherever you wish to insert a Form Field. 'Display the 'Select Name' dialog, which lets the user choose You can use the following macros with the above fields:ĭim strCode As String, strAddress As String Press Control+F9 to insert a set of Field Code Braces. Run a macro when a user double-clicks a button in the document