Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-23-2018, 04:28 AM
gmayor's Avatar
gmayor gmayor is offline Populating email subject from a MS-Word document Windows 10 Populating email subject from a MS-Word document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You need to define strsubject e.g.

Code:
Dim strSubject As String 'this line already in macro
Dim oPara As Range
Dim lngPara As Long
    For lngPara = 1 To ActiveDocument.Paragraphs.Count
        Set oPara = ActiveDocument.Paragraphs(lngPara).Range
        If Left(LCase(oPara.Text), 3) = "re:" Then
            oPara.End = oPara.End - 1
            oPara.MoveStartUntil Chr(32)
            oPara.Start = oPara.Start + 1
            strSubject = oPara.Text
            Exit For
        End If
    Next lngPara
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
email, letter, ms-word



Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating email subject from a MS-Word document Adding document fields to subject line of email russkris Word VBA 3 09-24-2017 08:18 PM
Populating a Word document with VBA\SQL shabbaranks Mail Merge 23 07-21-2015 01:31 PM
Populating email subject from a MS-Word document run word doc when a email is received with a certain subject based on rules megatronixs Outlook 3 10-18-2014 11:47 AM
Populating email subject from a MS-Word document Program to read Email subject line word by word john23# Outlook 1 02-14-2014 10:21 PM
Lack of email addresses auto-populating LarryK Outlook 0 10-10-2012 08:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:30 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft