![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi
![]() I'm new here, and new to Word VBA. I've been hunting around for information online for some time and am failing miserably to find what I want, I was hoping someone here may be able to help me, or at least let me know that what I want to do is not possible. This feels like a big ask, but I am hoping the answer is obvious - also if anyone has a link to a site with resources that have the answers to my queries then I'm happy to research myself. I've set up a form in word using controls and I assumed that if I gave them tags that I would be able to pull through whatever was written or selected in these fields to a certain area in an email, i.e. include the content of a control in the subject of an email. I have a control I've tagged as 'System' - this is a picklist of various systems, lets say sys1, sys2, sys3. I want this to appear after a string. So if I have - With EmailItem .Subject = "WO: RFW " What do I enter after this to get it to pick up what was entered in the System field? Also I want to be able to allow users to embed other documents in the form. Is it possible to input a control field that gives them the Browse function to upload? If there is, how would I get these documents included as attachments to the email that will be generated when the click submit? Any and all help would be greatly appreciated. I have spent days/weeks hunting for this and I'm just not finding it, or maybe I just don't get it. Thank you (so much) in advance Jacqui |
#2
|
||||
|
||||
![]()
For your first question, try
.Subject = "WO: RFW " & ActiveDocument.SelectContentControlsByTag("System" )(1).Range.Text For the attachments, I would assume there are two ways to approach this: 1. Actually embed the attachments into the Word doc and then work out how to extract them for the email 2. Create a list of filepaths and then have the email attachments built from these filepath strings. Personally, I would expect the second method to be easier to code and less error prone. The browse function is not something you would find as a native function in the Content Controls but it could be coded and executed either by entering a Content Control or maybe by a button on the ribbon. The code to select a file is often called FilePicker and there are plenty of samples showing how you use it. You could start here FileDialog object (Office) | Microsoft Docs or do a search for other examples.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
It appears that Andrew's code line has extraneous white space after "System"
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Email button in word document | ajh19742000 | Word | 1 | 07-21-2019 02:18 AM |
![]() |
phorsley | Word VBA | 1 | 10-17-2017 04:50 PM |
Submit to Email Command Button | rob7676 | Word VBA | 0 | 08-20-2015 05:05 AM |
![]() |
BlueMax | Word VBA | 3 | 08-07-2013 06:26 AM |
Adding an Email Button to a Word Document | maddoktor | Word | 0 | 12-01-2011 01:32 PM |