Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks
Selection Between Two Bookmarks Selection Between Two Bookmarks
Selection Between Two Bookmarks
Go Back  Xtreme Visual Basic Talk > > > Selection Between Two Bookmarks


Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2012, 03:48 AM
RR4Ever RR4Ever is offline
Newcomer
 
Join Date: Jan 2012
Posts: 1
Default Selection Between Two Bookmarks


Hello all

I have an issue and i am very new to VB, i am trying to make a selection between two bookmarks within a word document.
I am also executing this command from within Excel.
I am on VB 6.5.

I have already done my research and found this piece of code:


Quote:
Sub OpenAndReadWordDoc()
' assumes that the previous procedure has been executed
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim tString As String, tRange As Word.Range
Dim p As Long, r As Long
Workbooks.Add ' create a new workbook
With Range("A1")
.Formula = "Word Document Contents:"
.Font.Bold = True
.Font.Size = 14
.Offset(1, 0).Select
End With
r = 3 ' startrow for the copied text from the Word document
Set wrdApp = CreateObject("Word.Application")
'wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("had to remove for data protection reasons")
' example word operations

With wrdDoc
For p = 1 To .Paragraphs.Count

Set tRange = .Range(Start:=.Paragraphs(p).Range.Start, _
End:=.Paragraphs(p).Range.End)

tString = tRange.Text
tString = Left(tString, Len(tString) - 1)
' exclude the paragraph-mark
' check if the text has the content you want
If InStr(1, tString, "1") > 0 Then
' fill into active worksheet
ActiveSheet.Range("A" & r).Formula = tString
r = r + 1
End If
Next p
.Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing



End Sub
I have tweaked it and got it to work so that its copying all the words from the document but i need it to select between a range starting at one bookmark and ending at another.
I have highlighted the section im sure needs to be changed but due to lack of experience i dont know where to start.

As well as a solution please can you provide an explanation as i am trying to learn how to use VB not just looking for someone to do it for me.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks Selection Between Two Bookmarks
Selection Between Two Bookmarks
Selection Between Two Bookmarks
 
Selection Between Two Bookmarks
Selection Between Two Bookmarks
 
-->