Inserting a paragraph at end of document?
Author |
Message |
Lynn #1 / 14
|
 Inserting a paragraph at end of document?
I would like to insert a paragraph at the end of the active document, select it, then bold the contents. Is there a straightfoward way to do this? Thank you, in advance, for a reply!
|
Sun, 27 Mar 2005 01:59:34 GMT |
|
 |
Dave Let #2 / 14
|
 Inserting a paragraph at end of document?
Hi Lynn, I think this does what you've asked for: With ActiveDocument .Content.InsertAfter vbCrLf .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True End With HTH
Quote: > I would like to insert a paragraph at the end of the > active document, select it, then bold the contents. Is > there a straightfoward way to do this? > Thank you, in advance, for a reply!
|
Sun, 27 Mar 2005 02:32:01 GMT |
|
 |
Dave Let #3 / 14
|
 Inserting a paragraph at end of document?
Hi Lynn, I think this does what you've asked for:
Quote: > I would like to insert a paragraph at the end of the > active document, select it, then bold the contents. Is > there a straightfoward way to do this? > Thank you, in advance, for a reply!
|
Sun, 27 Mar 2005 02:31:40 GMT |
|
 |
Lynn #4 / 14
|
 Inserting a paragraph at end of document?
Dave, This is almost what I need. What I am trying to do is read a recordset object and produce a table of contents listing. What I want to result is this: BOLD TITLE 1 section section section BOLD TITLE 2 section... etc. The example you sent bolded everything from section A forward. Here is the code I am using where sTOCText is the heading that I would like to selectively "bold": If (bIsDivision = False) Then objWord.ActiveDocument.Sections.Last.Range.InsertAfter vbTab & sTOCText & vbCrLf Else With objWord.ActiveDocument .Content.InsertAfter sTOCText & vbCrLf .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True End With End If Thank you for the quick response to my first post!!! Quote: >-----Original Message----- >Hi Lynn, >I think this does what you've asked for: >With ActiveDocument > .Content.InsertAfter vbCrLf > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True >End With >HTH
>> I would like to insert a paragraph at the end of the >> active document, select it, then bold the contents. Is >> there a straightfoward way to do this? >> Thank you, in advance, for a reply! >.
|
Sun, 27 Mar 2005 02:39:25 GMT |
|
 |
Dave Let #5 / 14
|
 Inserting a paragraph at end of document?
Hi Lynn, Not sure, but I think you can use: If (bIsDivision = False) Then objWord.ActiveDocument.Sections.Last.Range.InsertAfter vbTab & sTOCText & vbCrLf Else With objWord.ActiveDocument .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True .Content.InsertAfter sTOCText & vbCrLf .Paragraphs(.Paragraphs.Count).Range.Font.Bold = False End With End If HTH
Quote: > Dave, > This is almost what I need. What I am trying to do is > read a recordset object and produce a table of contents > listing. > What I want to result is this: > BOLD TITLE 1 > section > section > section > BOLD TITLE 2 > section... > etc. > The example you sent bolded everything from section A > forward. > Here is the code I am using where sTOCText is the heading > that I would like to selectively "bold": > If (bIsDivision = False) Then > objWord.ActiveDocument.Sections.Last.Range.InsertAfter > vbTab & sTOCText & vbCrLf > Else > With objWord.ActiveDocument > .Content.InsertAfter sTOCText & vbCrLf > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True > End With > End If > Thank you for the quick response to my first post!!! > >-----Original Message----- > >Hi Lynn, > >I think this does what you've asked for: > >With ActiveDocument > > .Content.InsertAfter vbCrLf > > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True > >End With > >HTH
> >> I would like to insert a paragraph at the end of the > >> active document, select it, then bold the contents. Is > >> there a straightfoward way to do this? > >> Thank you, in advance, for a reply! > >.
|
Sun, 27 Mar 2005 03:15:17 GMT |
|
 |
Lynn #6 / 14
|
 Inserting a paragraph at end of document?
Dave, That din't really have the desired effect. Perhaps I should try something like this: 1. Make a range object? 2. Set the all the display properties [size, bolding, font] 3. Add the range object to the end of the document? Not sure if this is the way to go. Also, at what point to I insert my text string??? Lynn Quote: >-----Original Message----- >Hi Lynn, >Not sure, but I think you can use: >If (bIsDivision = False) Then > objWord.ActiveDocument.Sections.Last.Range.InsertAfter >vbTab & sTOCText & vbCrLf >Else > With objWord.ActiveDocument > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True > .Content.InsertAfter sTOCText & vbCrLf > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = False > End With >End If >HTH
>> Dave, >> This is almost what I need. What I am trying to do is >> read a recordset object and produce a table of contents >> listing. >> What I want to result is this: >> BOLD TITLE 1 >> section >> section >> section >> BOLD TITLE 2 >> section... >> etc. >> The example you sent bolded everything from section A >> forward. >> Here is the code I am using where sTOCText is the heading >> that I would like to selectively "bold": >> If (bIsDivision = False) Then >> objWord.ActiveDocument.Sections.Last.Range.InsertAfter >> vbTab & sTOCText & vbCrLf >> Else >> With objWord.ActiveDocument >> .Content.InsertAfter sTOCText & vbCrLf >> .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True >> End With >> End If >> Thank you for the quick response to my first post!!! >> >-----Original Message----- >> >Hi Lynn, >> >I think this does what you've asked for: >> >With ActiveDocument >> > .Content.InsertAfter vbCrLf >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True >> >End With >> >HTH
>> >> I would like to insert a paragraph at the end of the >> >> active document, select it, then bold the contents. Is >> >> there a straightfoward way to do this? >> >> Thank you, in advance, for a reply! >> >. >.
|
Sun, 27 Mar 2005 03:55:29 GMT |
|
 |
Dave Let #7 / 14
|
 Inserting a paragraph at end of document?
Hi Lynn, Is this iterative? That is, to get BOLD TITLE 1 section section section BOLD TITLE 2 section... It would appear that you're doing some type of loop. Is this true? It also sounds as if the whole process is a bit more complicated than inserting a paragraph and making it bold. If that's also true, then, yes, I agree with you that it could be more efficient to work with ranges (especially if you're in a loop). Can you extrapolate something useful from the following: Dim oRng As Range For i = 1 To 5 ActiveDocument.Content.InsertAfter vbCrLf Set oRng = ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range With oRng .Text = "Bold Heading " & i & vbCrLf .Font.Bold = True .Collapse wdCollapseEnd .Paragraphs(1).Range.Font.Bold = False .Text = "some text" & vbCrLf & "more text" End With Next i HTH
Quote: > Dave, > That din't really have the desired effect. Perhaps I > should try something like this: > 1. Make a range object? > 2. Set the all the display properties [size, bolding, font] > 3. Add the range object to the end of the document? > Not sure if this is the way to go. Also, at what point to > I insert my text string??? > Lynn > >-----Original Message----- > >Hi Lynn, > >Not sure, but I think you can use: > >If (bIsDivision = False) Then > > objWord.ActiveDocument.Sections.Last.Range.InsertAfter > >vbTab & sTOCText & vbCrLf > >Else > > With objWord.ActiveDocument > > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True > > .Content.InsertAfter sTOCText & vbCrLf > > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = False > > End With > >End If > >HTH
> >> Dave, > >> This is almost what I need. What I am trying to do is > >> read a recordset object and produce a table of contents > >> listing. > >> What I want to result is this: > >> BOLD TITLE 1 > >> section > >> section > >> section > >> BOLD TITLE 2 > >> section... > >> etc. > >> The example you sent bolded everything from section A > >> forward. > >> Here is the code I am using where sTOCText is the > heading > >> that I would like to selectively "bold": > >> If (bIsDivision = False) Then > >> objWord.ActiveDocument.Sections.Last.Range.InsertAfter > >> vbTab & sTOCText & vbCrLf > >> Else > >> With objWord.ActiveDocument > >> .Content.InsertAfter sTOCText & vbCrLf > >> .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True > >> End With > >> End If > >> Thank you for the quick response to my first post!!! > >> >-----Original Message----- > >> >Hi Lynn, > >> >I think this does what you've asked for: > >> >With ActiveDocument > >> > .Content.InsertAfter vbCrLf > >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = > True > >> >End With > >> >HTH
> >> >> I would like to insert a paragraph at the end of the > >> >> active document, select it, then bold the contents. > Is > >> >> there a straightfoward way to do this? > >> >> Thank you, in advance, for a reply! > >> >. > >.
|
Sun, 27 Mar 2005 04:27:12 GMT |
|
 |
Lynn Ki #8 / 14
|
 Inserting a paragraph at end of document?
Hello Dave, Yes, I am reading through records, but only a single time. I am moving through an ADODB.recordset object [looking at an Access database] and "building" a table of contents listing from a series of text strings. As I happen across a text string that is tagged as a division heading, I am hoping to write this text out [to the Word document] as bolded piece of text. Sounds simple enough, but pretty new to the Word object model and it is a bit confusing to me... Lynn Quote: >-----Original Message----- >Hi Lynn, >Is this iterative? That is, to get >BOLD TITLE 1 > section > section > section >BOLD TITLE 2 > section... >It would appear that you're doing some type of loop. Is this true? It also >sounds as if the whole process is a bit more complicated than inserting a >paragraph and making it bold. If that's also true, then, yes, I agree with >you that it could be more efficient to work with ranges (especially if >you're in a loop). Can you extrapolate something useful from the following: >Dim oRng As Range >For i = 1 To 5 > ActiveDocument.Content.InsertAfter vbCrLf > Set oRng = >ActiveDocument.Paragraphs
(ActiveDocument.Paragraphs.Count).Range Quote: > With oRng > .Text = "Bold Heading " & i & vbCrLf > .Font.Bold = True > .Collapse wdCollapseEnd > .Paragraphs(1).Range.Font.Bold = False > .Text = "some text" & vbCrLf & "more text" > End With >Next i >HTH
>> Dave, >> That din't really have the desired effect. Perhaps I >> should try something like this: >> 1. Make a range object? >> 2. Set the all the display properties [size, bolding, font] >> 3. Add the range object to the end of the document? >> Not sure if this is the way to go. Also, at what point to >> I insert my text string??? >> Lynn >> >-----Original Message----- >> >Hi Lynn, >> >Not sure, but I think you can use: >> >If (bIsDivision = False) Then >> > objWord.ActiveDocument.Sections.Last.Range.InsertAfter >> >vbTab & sTOCText & vbCrLf >> >Else >> > With objWord.ActiveDocument >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True >> > .Content.InsertAfter sTOCText & vbCrLf >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = False >> > End With >> >End If >> >HTH
>> >> Dave, >> >> This is almost what I need. What I am trying to do is >> >> read a recordset object and produce a table of contents >> >> listing. >> >> What I want to result is this: >> >> BOLD TITLE 1 >> >> section >> >> section >> >> section >> >> BOLD TITLE 2 >> >> section... >> >> etc. >> >> The example you sent bolded everything from section A >> >> forward. >> >> Here is the code I am using where sTOCText is the >> heading >> >> that I would like to selectively "bold": >> >> If (bIsDivision = False) Then
objWord.ActiveDocument.Sections.Last.Range.InsertAfter Quote: >> >> vbTab & sTOCText & vbCrLf >> >> Else >> >> With objWord.ActiveDocument >> >> .Content.InsertAfter sTOCText & vbCrLf >> >> .Paragraphs(.Paragraphs.Count).Range.Font.Bold = True >> >> End With >> >> End If >> >> Thank you for the quick response to my first post!!! >> >> >-----Original Message----- >> >> >Hi Lynn, >> >> >I think this does what you've asked for: >> >> >With ActiveDocument >> >> > .Content.InsertAfter vbCrLf >> >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = >> True >> >> >End With >> >> >HTH
>> >> >> I would like to insert a paragraph at the end of the >> >> >> active document, select it, then bold the contents. >> Is >> >> >> there a straightfoward way to do this? >> >> >> Thank you, in advance, for a reply! >> >> >. >> >. >.
|
Sun, 27 Mar 2005 04:43:24 GMT |
|
 |
Dave Let #9 / 14
|
 Inserting a paragraph at end of document?
Hi Lynn, Does the following get you closer (you'll have to modify it to use objWord): Dim oRng As Range Set oRng = ActiveDocument.Range oRng.Collapse Direction:=wdCollapseEnd If (bIsDivision = False) Then With oRng .Paragraphs(1).Range.Font.Bold = False .InsertAfter vbTab & sTOCText & vbCrLf .Collapse Direction:=wdCollapseEnd End With Else With oRng .Paragraphs(1).Range.Font.Bold = True .InsertAfter sTOCText & vbCrLf .Collapse Direction:=wdCollapseEnd End With End If HTH
Quote: > Hello Dave, > Yes, I am reading through records, but only a single > time. I am moving through an ADODB.recordset object > [looking at an Access database] and "building" a table of > contents listing from a series of text strings. As I > happen across a text string that is tagged as a division > heading, I am hoping to write this text out [to the Word > document] as bolded piece of text. > Sounds simple enough, but pretty new to the Word object > model and it is a bit confusing to me... > Lynn > >-----Original Message----- > >Hi Lynn, > >Is this iterative? That is, to get > >BOLD TITLE 1 > > section > > section > > section > >BOLD TITLE 2 > > section... > >It would appear that you're doing some type of loop. Is > this true? It also > >sounds as if the whole process is a bit more complicated > than inserting a > >paragraph and making it bold. If that's also true, then, > yes, I agree with > >you that it could be more efficient to work with ranges > (especially if > >you're in a loop). Can you extrapolate something useful > from the following: > >Dim oRng As Range > >For i = 1 To 5 > > ActiveDocument.Content.InsertAfter vbCrLf > > Set oRng = > >ActiveDocument.Paragraphs > (ActiveDocument.Paragraphs.Count).Range > > With oRng > > .Text = "Bold Heading " & i & vbCrLf > > .Font.Bold = True > > .Collapse wdCollapseEnd > > .Paragraphs(1).Range.Font.Bold = False > > .Text = "some text" & vbCrLf & "more text" > > End With > >Next i > >HTH
> >> Dave, > >> That din't really have the desired effect. Perhaps I > >> should try something like this: > >> 1. Make a range object? > >> 2. Set the all the display properties [size, bolding, > font] > >> 3. Add the range object to the end of the document? > >> Not sure if this is the way to go. Also, at what point > to > >> I insert my text string??? > >> Lynn > >> >-----Original Message----- > >> >Hi Lynn, > >> >Not sure, but I think you can use: > >> >If (bIsDivision = False) Then > >> > objWord.ActiveDocument.Sections.Last.Range.InsertAfter > >> >vbTab & sTOCText & vbCrLf > >> >Else > >> > With objWord.ActiveDocument > >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = > True > >> > .Content.InsertAfter sTOCText & vbCrLf > >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = > False > >> > End With > >> >End If > >> >HTH
> >> >> Dave, > >> >> This is almost what I need. What I am trying to do > is > >> >> read a recordset object and produce a table of > contents > >> >> listing. > >> >> What I want to result is this: > >> >> BOLD TITLE 1 > >> >> section > >> >> section > >> >> section > >> >> BOLD TITLE 2 > >> >> section... > >> >> etc. > >> >> The example you sent bolded everything from section A > >> >> forward. > >> >> Here is the code I am using where sTOCText is the > >> heading > >> >> that I would like to selectively "bold": > >> >> If (bIsDivision = False) Then > objWord.ActiveDocument.Sections.Last.Range.InsertAfter > >> >> vbTab & sTOCText & vbCrLf > >> >> Else > >> >> With objWord.ActiveDocument > >> >> .Content.InsertAfter sTOCText & vbCrLf > >> >> .Paragraphs(.Paragraphs.Count).Range.Font.Bold = > True > >> >> End With > >> >> End If > >> >> Thank you for the quick response to my first post!!! > >> >> >-----Original Message----- > >> >> >Hi Lynn, > >> >> >I think this does what you've asked for: > >> >> >With ActiveDocument > >> >> > .Content.InsertAfter vbCrLf > >> >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = > >> True > >> >> >End With > >> >> >HTH
> >> >> >> I would like to insert a paragraph at the end of > the > >> >> >> active document, select it, then bold the > contents. > >> Is > >> >> >> there a straightfoward way to do this? > >> >> >> Thank you, in advance, for a reply! > >> >> >. > >> >. > >.
|
Sun, 27 Mar 2005 04:59:04 GMT |
|
 |
Lynn Ki #10 / 14
|
 Inserting a paragraph at end of document?
Dave, Thank you very much for your patience with my steep learning curve! The use of the range object was just the ticket. I suppose I can also embellish the range object with other display properties [oRng.Font.Size = 24, oRng.Font.Name = "Arial"] as well. I will be sure and return the favor for other posters as well [if I can]. You solution will definitely become part of OUR knowledge base :) Thank you again! Regards, Lynn Kim
http://www.brodiegroup.com Quote: >-----Original Message----- >Hi Lynn, >Does the following get you closer (you'll have to modify it to use objWord): >Dim oRng As Range >Set oRng = ActiveDocument.Range >oRng.Collapse Direction:=wdCollapseEnd >If (bIsDivision = False) Then > With oRng > .Paragraphs(1).Range.Font.Bold = False > .InsertAfter vbTab & sTOCText & vbCrLf > .Collapse Direction:=wdCollapseEnd > End With >Else > With oRng > .Paragraphs(1).Range.Font.Bold = True > .InsertAfter sTOCText & vbCrLf > .Collapse Direction:=wdCollapseEnd > End With >End If >HTH
>> Hello Dave, >> Yes, I am reading through records, but only a single >> time. I am moving through an ADODB.recordset object >> [looking at an Access database] and "building" a table of >> contents listing from a series of text strings. As I >> happen across a text string that is tagged as a division >> heading, I am hoping to write this text out [to the Word >> document] as bolded piece of text. >> Sounds simple enough, but pretty new to the Word object >> model and it is a bit confusing to me... >> Lynn >> >-----Original Message----- >> >Hi Lynn, >> >Is this iterative? That is, to get >> >BOLD TITLE 1 >> > section >> > section >> > section >> >BOLD TITLE 2 >> > section... >> >It would appear that you're doing some type of loop. Is >> this true? It also >> >sounds as if the whole process is a bit more complicated >> than inserting a >> >paragraph and making it bold. If that's also true, then, >> yes, I agree with >> >you that it could be more efficient to work with ranges >> (especially if >> >you're in a loop). Can you extrapolate something useful >> from the following: >> >Dim oRng As Range >> >For i = 1 To 5 >> > ActiveDocument.Content.InsertAfter vbCrLf >> > Set oRng = >> >ActiveDocument.Paragraphs >> (ActiveDocument.Paragraphs.Count).Range >> > With oRng >> > .Text = "Bold Heading " & i & vbCrLf >> > .Font.Bold = True >> > .Collapse wdCollapseEnd >> > .Paragraphs(1).Range.Font.Bold = False >> > .Text = "some text" & vbCrLf & "more text" >> > End With >> >Next i >> >HTH
>> >> Dave, >> >> That din't really have the desired effect. Perhaps I >> >> should try something like this: >> >> 1. Make a range object? >> >> 2. Set the all the display properties [size, bolding, >> font] >> >> 3. Add the range object to the end of the document? >> >> Not sure if this is the way to go. Also, at what point >> to >> >> I insert my text string??? >> >> Lynn >> >> >-----Original Message----- >> >> >Hi Lynn, >> >> >Not sure, but I think you can use: >> >> >If (bIsDivision = False) Then
objWord.ActiveDocument.Sections.Last.Range.InsertAfter Quote: >> >> >vbTab & sTOCText & vbCrLf >> >> >Else >> >> > With objWord.ActiveDocument >> >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = >> True >> >> > .Content.InsertAfter sTOCText & vbCrLf >> >> > .Paragraphs(.Paragraphs.Count).Range.Font.Bold = >> False >> >> > End With >> >> >End If >> >> >HTH
>> >> >> Dave, >> >> >> This is almost what I need. What I am trying to do >> is >> >> >> read a recordset object and produce a table of >> contents >> >> >> listing. >> >> >> What I want to result is this: >> >> >> BOLD TITLE 1 >> >> >> section >> >> >> section >> >> >> section >> >> >> BOLD TITLE 2 >> >> >> section... >> >> >> etc. >> >> >> The example you sent bolded everything from section A >> >> >> forward. >> >> >> Here is the code I am using where sTOCText is the >> >> heading >> >> >> that I would like to selectively "bold": >> >> >> If (bIsDivision = False) Then >> objWord.ActiveDocument.Sections.Last.Range.InsertAfter >> >> >> vbTab & sTOCText & vbCrLf >> >> >> Else >> >> >> With objWord.ActiveDocument >> >> >> .Content.InsertAfter sTOCText & vbCrLf >> >> >> .Paragraphs(.Paragraphs.Count).Range.Font.Bold = >> True >> >> >> End With >> >> >> End If >> >> >> Thank you for the quick response to my first post!!! >> >> >> >-----Original Message----- >> >> >> >Hi Lynn, >> >> >> >I think this does what you've asked for: >> >> >> >With ActiveDocument >> >> >> > .Content.InsertAfter vbCrLf >> >> >> > .Paragraphs
(.Paragraphs.Count).Range.Font.Bold = Quote: >> >> True >> >> >> >End With >> >> >> >HTH
Quote: >> >> >> >> I would like to insert a paragraph at the end of >> the >> >> >> >> active document, select it, then bold the >> contents. >> >> Is >> >> >> >> there a straightfoward way to do this? >> >> >> >> Thank you, in advance, for a reply! >> >> >> >. >> >> >. >> >. >.
|
Sun, 27 Mar 2005 05:13:51 GMT |
|
|
|