Computing.Net > Forums > Office Software > Get paragraphs from MS word in VBA

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Get paragraphs from MS word in VBA

Reply to Message Icon

Name: Noob22
Date: July 27, 2005 at 13:43:57 Pacific
OS: xp pro
CPU/Ram: pentium 4/ 512
Comment:

Hey guys Im creating a macro that takes a specific paragraph from a word file and then dumps it into Excel. I have some code but it doesn't work:

Private Sub ImportCommandButton_Click()
Dim FilePath As String
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim para As Paragraph
FilePath = Application.GetOpenFilename("Microsoft Word Document (*.doc), *.doc")
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Documents.Add ' create a new document
Set wrdDoc = wrdApp.Documents.Open(FilePath)
wrdDoc.Select
para = wrdDoc.para(1)
Worksheets("sheet1").Range("A1").Value = para
wrdDoc.Close
End Sub

The error is Invalid use of property where it says "para = wrdDoc.para(1)

Any help is appreciated!!


If a person is perseverant, although he/she is hard of understanding, will become intelligent; and although he/she is weak will be transformed into strong



Sponsored Link
Ads by Google

Response Number 1
Name: rhawk7938
Date: July 28, 2005 at 11:43:11 Pacific
Reply:

Just a thought. Is "para" a valid variable name?


0

Response Number 2
Name: Noob22
Date: July 28, 2005 at 12:33:38 Pacific
Reply:

I don't see why not!!

If a person is perseverant, although he/she is hard of understanding, will become intelligent; and although he/she is weak will be transformed into strong


0

Response Number 3
Name: Grok Lobster
Date: July 28, 2005 at 15:02:46 Pacific
Reply:

Try using para = wrdDoc.paragraphs(1) and then learn to use the Help features.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Get paragraphs from MS word in VBA

To delete Spanish from MS SpellCheckerer www.computing.net/answers/office/to-delete-spanish-from-ms-spellcheckerer/8973.html

MS Word Footer not Copying to Notep www.computing.net/answers/office/ms-word-footer-not-copying-to-notep/6597.html

Getting a summary of words in Word www.computing.net/answers/office/getting-a-summary-of-words-in-word/2432.html