PDA

View Full Version : Getting the value of a mail merge field



MikeroSoft
04-26-2006, 02:52 PM
my code :
ActiveDocument.Sections(ActiveDocument.Sections.Count).Headers(1) _
.Range.FormattedText
has given me this result:

?Institution??s Statement of Changes in Partner?s Capital
Period from October 1, 2005 through December 31, 2005
Unaudited

<<Institution>> is from a mail merge i need to save the file as that value but cant figure how to get that value.....


any help,, please if you can I am running out of time

MikeroSoft
04-26-2006, 03:30 PM
Well i got it, this is slopy as all hll but :

Dim removeString As String
removeString = "'s Statement of Changes in Partner's"


If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.EndKey Unit:=wdLine, Extend:=wdExtend


Dim fileName As String
selectLen = Len(Selection)

fileName = Left(Selection, selectLen - Len(removeString) - 1)

MsgBox fileName


If anyone can offer an improvement i woud appreciate it

Edited 27-Apr-06 by GeekGirlau (insert vba tags)