Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-10-2014, 12:02 AM
Sektor Sektor is offline Confusion about paragraphs Windows 8 Confusion about paragraphs Office 2013
Novice
Confusion about paragraphs
 
Join Date: Mar 2014
Location: Russia
Posts: 6
Sektor is on a distinguished road
Default Confusion about paragraphs

I have created new document and inserted two paragraphs. First paragraph holds text "par2" and second paragraph holds text "par2". Now I execute the following macro (comments explain behavior).



Code:
Sub TestParagraphs()

    Dim p As Paragraph
    
    With ActiveDocument
        
        ' Variable "p" seems to hold reference
        ' to new (third) paragraph....
        Set p = .Paragraphs.Add()
        ' ...or does it?
        p.Range.Text = "par3"
        
        ' What we get here is that third paragraph is gone
        ' AND second paragraph now holds "par3" text.
        
        ' This is work around, which works.
        .Paragraphs.Add
        Set p = .Paragraphs(.Paragraphs.Count)
        p.Range.Text = "par3"
        
    End With

End Sub
According to documentation "Paragraphs.Add returns a Paragraph object that represents a new, blank paragraph added to a document." What I missed?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusion over licences Nez Office 5 02-03-2014 03:29 AM
Confusion about paragraphs Word template confusion portia Word 8 11-29-2011 02:08 PM
Confusion about paragraphs Email confusion chris29 Outlook 1 08-24-2011 01:22 PM
Confusion about paragraphs Multiple referencing confusion ridge1988 Word 2 03-31-2011 07:42 PM
Windows Update confusion Quicksilver Office 0 06-24-2010 12:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft