Reply
 
Thread Tools Display Modes
  #1   Report Post  
 
Posts: n/a
Default Updating Text in Field Codes/VBA error

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help, problem with text field in word 2003 Salvatore Microsoft Word Help 1 January 21st 05 03:40 PM
Outline Renee Hendershott Page Layout 2 December 25th 04 02:49 PM
Converting field results to hard text Thomas Payne Formatting Long Documents 7 December 10th 04 06:39 PM
Text Form Field Ref in Footer Won't Update on Screen StarWine Microsoft Word Help 3 December 6th 04 06:17 PM
Auto Jump Text Field to Text Field jhnbernhard Tables 1 November 17th 04 02:13 PM


All times are GMT +1. The time now is 10:36 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"