Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I have a mail merge document that reads from a text file. Most of the
values are retrieved using an IF statement that returns a blank if the value is false. When I try accessing the field code to update part of the text (such as, for instance, a year), save the document, close and re-open to run the merge I get an error code 582 (Requested object is not available) on the wdSentToNewDocument line of the auto_open macro(see below) With ActiveDocument.MailMerge ..Destination = wdSendToNewDocument ..Execute End With This is the code in its entirety - I realise it's been updated from WordBasic, and I'm really trying to avoid re-writing the whole thing if it's something straightforward. Any help appreciated!! GregL Public Sub MAIN() WordBasic.FilePageSetup Tab:="3", PaperSize:="9", TopMargin:="2 cm", BottomMargin:="1 cm", LeftMargin:="2.5 cm", RightMargin:="2 cm", Gutter:="0 cm", PageWidth:="21 cm", PageHeight:="29.7 cm", Orientation:=0, FirstPage:=0, OtherPages:=0, VertAlign:=0, ApplyPropsTo:=4, FacingPages:=0, HeaderDistance:="1 cm", FooterDistance:="1 cm", SectionStart:=2, OddAndEvenPages:=0, DifferentFirstPage:=0, Endnotes:=0, LineNum:=0, StartingNum:="", FromText:="", CountBy:="0", NumMode:=-1 ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader Selection.WholeStory Selection.Fields.Unlink ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument With ActiveDocument.Range(Start:=ActiveDocument.Content .Start, End:=ActiveDocument. _ Content.End).PageSetup ..LineNumbering.Active = False ..Orientation = wdOrientPortrait ..TopMargin = CentimetersToPoints(2) ..BottomMargin = CentimetersToPoints(2) ..LeftMargin = CentimetersToPoints(2.5) ..RightMargin = CentimetersToPoints(2) ..Gutter = CentimetersToPoints(0) ..HeaderDistance = CentimetersToPoints(1) ..FooterDistance = CentimetersToPoints(2) ..PageWidth = CentimetersToPoints(21) ..PageHeight = CentimetersToPoints(29.7) ..FirstPageTray = wdPrinterLargeCapacityBin ..OtherPagesTray = wdPrinterLargeCapacityBin ..OddAndEvenPagesHeaderFooter = False ..DifferentFirstPageHeaderFooter = False ..VerticalAlignment = wdAlignVerticalTop ..SuppressEndnotes = False ..MirrorMargins = False End With With ActiveDocument.MailMerge ..Destination = wdSendToNewDocument ..Execute End With ActiveWindow.View.Type = wdPageView Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find ..Text = "^b" ..Replacement.Text = "" ..Forward = True ..Wrap = wdFindContinue ..Format = False ..MatchCase = False ..MatchWholeWord = False ..MatchWildcards = False ..MatchSoundsLike = False ..MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Selection.HomeKey Unit:=wdStory With ActiveDocument ..TrackRevisions = True ..PrintRevisions = True ..ShowRevisions = True End With Selection.WholeStory Selection.LanguageID = wdEnglishUK Selection.HomeKey Unit:=wdStory WordBasic.setDocumentVar "Type", "aide" ChangeFileOpenDirectory "S:\Docs\" Windows("AidemXP.dot").Close (wdDoNotSaveChanges) End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
help, problem with text field in word 2003 | Microsoft Word Help | |||
Outline | Page Layout | |||
Converting field results to hard text | Formatting Long Documents | |||
Text Form Field Ref in Footer Won't Update on Screen | Microsoft Word Help | |||
Auto Jump Text Field to Text Field | Tables |