Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation - Delete Cell from a Table in Footer? 1

Status
Not open for further replies.

kazl

Programmer
Dec 9, 2002
68
GB
Hi There. Can you help with Headers and Footers please?

Is there a simple way to access part of a table within a footer. I have a 1 row, 4 column table used for company info on a letterhead. Sometimes I need to remove the text from the last cell.

I know that to delete the whole footer I can use:
Code:
oDocument.Sections[1].Footers[1].Range.Delete

And I could go into footer and delete the 4th cell using:
Code:
*- open the Footer
WITH oDocument.ActiveWindow.ActivePane.View
	.Type = 3      && wdPrintView
	.SeekView = 10 && wdSeekCurrentPageFooter
ENDWITH
*- this appears to go straight to the the table
*- move right three cells to number 4 then delete contents
.MoveRight( 12, 3 )	&& wdCell 12
.Delete
*- close footer
oDocument.ActiveWindow.ActivePane.View.SeekView = 0 &&wdSeekMainDocument

I can't rely on this method. I know it will go wrong while not visible and running off batches of documents.

So is there a way to directly delete the cell? (like you can in the main document using:)
Code:
oDocument.Tables[1].Rows[1].Cells[1].Range.Delete

Thank you.
Kaz.




 
Kaz,

Try this:
Code:
oword = GETOBJECT(,'word.application')
oword.ActiveDocument.Sections(1).Footers(1).Range.Select
osel = oword.Selection
osel.Tables(1).Cell(2,1).Select
oword.Selection.Text=[]

This should blank the cell contents.

If you want to delete the cell, try:
Code:
oword = GETOBJECT(,'word.application')
oword.ActiveDocument.Sections(1).Footers(1).Range.Select
osel = oword.Selection
osel.Tables(1).Cell(2,1).Delete

Hope that helps,

Stewart
 
Hey Stewart

That's just the ticket. I tried so many combinations, but didn't have the range selected.

Thank you very much and have a Star.

Cheers!

Kaz.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top