Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Before table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frantisek Horalek - 21 Mar 2005 15:12 GMT
Hello,
I need to place some text just before every table in the document
which (the table) has the first-cell-text like "This example".
Is it possible?
Pushing me forward will be enough, I will complete that script with
your suggestions...

Thank you!
Jonathan West - 21 Mar 2005 16:02 GMT
> Hello,
> I need to place some text just before every table in the document
[quoted text clipped - 4 lines]
>
> Thank you!

Something like this should do

Dim oTable as Table
For each oTable in ActiveDocument.Tables
 If Instr(oTable.Cell(1, 1).Range.Text, "This example") > 0 Then
   With oTable.Range.Paragraphs.First.Previous.Range
     .Characters.Last.InsertParagraphBefore
     .InsertBefore "Table Caption"
   End With
 End If
Next oTable

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Frantisek Horalek - 22 Mar 2005 00:42 GMT
>Something like this should do

Great, it works!

Now I am looking for reason to "group" this to be able to press Back
button just once to get to the situation BEFORE using macro. Now it is
on many clicks on Back button.
I it possible?
I used that in Corel programming vba, but here this:
==========
ActiveDocument.BeginCommandGroup "StredPravyDolni"
.
.
.
ActiveDocument.EndCommandGroup
==========

do not work.

Thank you!
Jonathan West - 22 Mar 2005 02:04 GMT
> >Something like this should do
>
[quoted text clipped - 4 lines]
> on many clicks on Back button.
> I it possible?

No, that is not possible.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Helmut Weber - 22 Mar 2005 04:29 GMT
Hi Frantisek,

as far as I see, Jonathan's example does the following:
It creates a new paragraph immediately before the table,
leaves that paragraph empty, and inserts "table caption"
at the beginning of the paragraph predecing the newly
created paragraph!

Redoing it all would in my example mean,
delete all paragraphs immediately preceding tables,
and is not a big problem, if I get you right.

' ------
Sub test8948()
Dim oTable As Table
Dim rtmp As Range
For Each oTable In ActiveDocument.Tables
Set rtmp = oTable.Range.Cells(1).Range
  rtmp.Select
  Selection.SplitTable
  rtmp.InsertBefore "table heading"
Next oTable
' redo
For Each oTable In ActiveDocument.Tables
  oTable.Range.Paragraphs(1).Previous.Range.Delete
Next oTable
End Sub
' ----

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Helmut Weber - 21 Mar 2005 16:09 GMT
Hi Frantisek,

>Pushing me forward will be enough,

If so:

With Selection
  .Tables(1).Select
  .Collapse
  .SplitTable
  .InsertBefore "aasdasdskd"
End With

Need help on how to process all tables?

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.