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 / July 2007

Tip: Looking for answers? Try searching our database.

Populating  blank sections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arry Potter - 28 Jul 2007 23:54 GMT
Hi All,
           
             I have a word document with standard heading and sub heading
sections.I wanted to write a macro which could populate the corresponding
heading or subheading sections with some standard text.The only clause is
that when heading is blank , I want the population to occur. else it must  
not touch the section.

Current Document

1 Heading
blank
1.1 Subheading
not blank

After Running the Macro

1 Heading
Its a heading <change>
1.1 Subheading
not blank <no change>
Arry Potter - 29 Jul 2007 00:20 GMT
My Configuration is word 2003, Win Xp and I have posted this in foll
newsgroup(programming,general and new users). Just want to see some quick
response as I need to get back to my customers on this.

> Hi All,
>              
[quoted text clipped - 17 lines]
> 1.1 Subheading
> not blank <no change>
old man - 29 Jul 2007 00:42 GMT
Hi Arry,

There are three possible headers associated with a section
(wdHeaderFooterEvenPages, wdHeaderFooterFirstPage,wdHeaderFooterPrimary) but
I am just checking the primary header. All headers default to a chr (13) and
if  you want to you can change to code to trim the header before checking the
length.

Sub f1()
Dim section1 As Section
Dim str1 As String

For Each section1 In ActiveDocument.Sections
   
   str1 = section1.Headers(wdHeaderFooterPrimary).Range.Text
   If Len(str1) = 1 And Asc(str1) = 13 Then
          section1.Headers(wdHeaderFooterPrimary).Range.Text = "Sample Text"
   End If
   
Next

End Sub

Old Man

> My Configuration is word 2003, Win Xp and I have posted this in foll
> newsgroup(programming,general and new users). Just want to see some quick
[quoted text clipped - 21 lines]
> > 1.1 Subheading
> > not blank <no change>
Russ - 29 Jul 2007 00:53 GMT
Ey Arry,
Insert Autotext entries that consist of formatted boilerplate text and
images, etc. Also Mail Merge Methods. Unless you are dynamically creating
the text that you want inserted.
Are your headings formatted with a particular list style? Just search for
two paragraphs in a row with the same list style.

Get clues from this link:
<http://word.mvps.org/faqs/numbering/liststring.htm>

> Hi All,
>              
[quoted text clipped - 17 lines]
> 1.1 Subheading
> not blank <no change>

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Arry Potter - 29 Jul 2007 03:38 GMT
Hi Guys,
                           I think I have put a sample copy of my document
at the following path.

http://www.geocities.com/velabhigyan/Customerdetails.doc

I guess I am getting a bit confused following the instructions. Could you
check the document and give me your feedbacks

Regards,
Arvind

> Ey Arry,
> Insert Autotext entries that consist of formatted boilerplate text and
[quoted text clipped - 27 lines]
> > 1.1 Subheading
> > not blank <no change>
Russ - 29 Jul 2007 08:43 GMT
Arvind,
See if this subroutine does what you want.

Public Sub FindNoDataLocation()
Dim myDoc As Word.Document
Dim aParagraph As Word.Paragraph
Dim aRange As Word.Range

Set myDoc = ActiveDocument
For Each aParagraph In myDoc.Paragraphs
   If InStr(aParagraph.Style, "Heading 1") <> 0 _
       Or InStr(aParagraph.Style, "Heading 2") <> 0 Then
       Set aRange = aParagraph.Range
       aRange.Move Unit:=wdParagraph, Count:=1
       aRange.Expand Unit:=wdParagraph
      If aRange.Characters.Count = 1 Then
           aRange.Collapse
           aRange.InsertBefore "TBC"
           aRange.Font.Animation = wdAnimationMarchingRedAnts
      ElseIf InStr(aRange.Paragraphs(1).Style, "Heading ") <> 0 Then
           Set aRange = aParagraph.Range
           aRange.Collapse Direction:=wdCollapseEnd
           aRange.Move Unit:=wdCharacter, Count:=-1
           aRange.Select
           With Selection
               .TypeParagraph
               .TypeText "TBC"
               .MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
           End With
           Set aRange = Selection.Range
           aRange.Font.Animation = wdAnimationMarchingRedAnts
       End If
   End If
Next aParagraph
End Sub

> Hi Guys,
>                             I think I have put a sample copy of my document
[quoted text clipped - 39 lines]
>>> 1.1 Subheading
>>> not blank <no change>

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Arry Potter - 30 Jul 2007 12:20 GMT
THANKS ALL IT SOLVED MY PROBLEM. RUSS,OLDMAN ARE THE BEST!
 
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.