visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
294 experts, 1172 registered users, 1625 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Languages :: VBA (Office) :: Controlling Word from Access; error on WholeStory method


By: progGoon U.S.A.  Date: 25/04/2003 00:00:00  English  Points: 75 Status: Answered
Quality : Excellent
I am using Office XP, and I'm controlling Word from Access. Here's the big picture of what I'm doing:

I create a new document, copy data from my database into the document at specified bookmarks. Then with some of the records, I need to copy and paste the entire text of a separate document into the new document. I have no problem with any of the code until I am trying to select the entire text of the second document. The error happens on the Selection.WholeStory line - I get Run-time error 438 - Object doesn't support this property or method.

With wd
.Documents.Open "C:\TestDoc.doc" 'Opening the second document
With .Documents("TestDoc.doc")
.Selection.WholeStory 'Error 438 happens on this line
.Selection.Copy
.Close
End With
.Windows(2).Activate 'Referring to the new document I've already created
.Selection.PasteAndFormat (wdPasteDefault)
End With

Any help is greatly appreciated. Thanks so much!!
By: VGR Date: 26/04/2003 05:27:00 English  Type : Answer
apparently, WholeStory (new for me :D ) doesn't exist, doesn't exist in all versions of Word, or isn't supported by the COM model...
I suggest you find a more classical workaround, like ".SelectAll" or Selection.Start=, Selection.End=,Selection.Copy;
By: gasmanp Date: 10/04/2008 13:43:46 English  Type : Comment
Your second with means that what you are effectively doing is:

wd.documents("TestDoc.doc").Selection.WholeStory

but Selection is an property of the application object, not the document one.

Try:

wd.StoryRanges(wdMainTextStory).WholeStory (assuming wd is an application object). The wsMainTextStory is the body of the document, if you wanted to copy headers, footers etc then you do the same with the different story

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 66.116090 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page