LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Problems automating Word from Excel

I am running Office 2002.

I have Excel documents which "name" certain pages in a given Word
document. I want the Excel document to cause Word to edit that document
so it only consists of the named pages.
My model for text deletion is selection.extend; selection.gotoend;
selection.delete.
I find that selection.extend does not work.
e.g.
This does not work:
Set oWD = CreateObject("Word.Application")
With oWD
.Visible = True
.Documents.Open Filename:="C:\foo.doc", ReadOnly:=True
.Selection.Extend ' This is ineffective
' .Selection.ExtendMode = True ' This is also ineffective
.Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="4"
.Selection.Delete Unit:=wdCharacter, Count:=1
End With

OTOH, this does work:
Set oWD = CreateObject("Word.Application")
With oWD
.Visible = True
.Documents.Open Filename:="C:\foo.doc", ReadOnly:=True
.Run "ZapTOC"
End With

where ZapTOC in foo.doc is set as:
Sub ZapTOC()
Selection.Extend
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="4"
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub

Can anyone here advise on such automation?
--
Walter Briscoe
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating a copy from Excel to Word tigs Excel Programming 5 April 29th 10 02:12 PM
Automating Excel from Word - How to Sort a Range of Cells Doug Robbins - Word MVP on news.microsoft.com Excel Programming 6 March 16th 09 12:34 PM
Automating import of Word tables into Excel Han Excel Discussion (Misc queries) 0 January 18th 06 08:42 AM
Automating Word from Excel John Wilson Excel Programming 0 June 30th 04 09:55 PM
Real problems automating a mail merge nath Excel Programming 0 June 10th 04 11:32 AM


All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"