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

Tip: Looking for answers? Try searching our database.

Inserting large text into word document using Find Replace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim - 18 Apr 2007 15:00 GMT
Hello All,

I have attempted to use the .Content.Find.Execute() function while setting
the replacewith: parameter to a variable.

The code works however since the parameter is a string with a size
limitation I run into issues when the retrieved value is extremely large.

I was wondering if anyone has used this functionality to some how set the
cursor poistion in Word and then insert a value from a dataset directly into
a word document?

Any help would be appreciated.

Thanks!
Tim - 18 Apr 2007 15:04 GMT
I should add this code is being developed in vb.net for a stand alone windows
application.

> Hello All,
>
[quoted text clipped - 11 lines]
>
> Thanks!
Tim - 19 Apr 2007 14:02 GMT
The following code worked for moving the replacing the token, moving the
cursor and using a dataset.table value for inserting the text as opposed to
attempting to assign the value to a string

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
       Dim app As New Microsoft.Office.Interop.Word.Application
       Dim doc As Microsoft.Office.Interop.Word.Document =
app.Documents.Add("test7")
       Dim para1 As Microsoft.Office.Interop.Word.Paragraph
       Dim docString As String
       Dim count As Integer
       Dim test As Boolean

       cmdcommand.Connection = GetConnection()
       cmdcommand.CommandText = "SELECT
field_eis_purpose_value,field_eis_agenda_value,field_eis_notes_value,field_eis_requirements_value," & _
       
"field_eis_action_items_value,field_eis_open_issues_value,field_eis_meeting_date_value,field_eis_attendees_value " & _
       "FROM content_type_eis_meeting_notes meeting " & _
       "INNER JOIN (select max(vid) as vid from
content_type_eis_meeting_notes group by nid) m2 ON " & _
       "m2.vid = meeting.vid LEFT OUTER JOIN content_field_eis_notes note
on " & _
       "note.vid = meeting.vid LEFT OUTER JOIN
content_field_eis_open_issues issue ON " & _
       "note.vid = issue.vid WHERE meeting.nid = 681"

       daDataAdapter.SelectCommand = cmdcommand
       'Populate temp dataset
       daDataAdapter.Fill(dsDataSetFinal)

       count = 0
       test = True

       Do While test
           ReplaceText(app, count)
           app.Selection.Text = dsDataSetFinal.Tables(0).Rows(0)(count)
           count += 1
           test = doc.Content.Find.Execute(findtext:="{Text}")
       Loop
       doc.SaveAs("Test123")
       app.Visible = True
   End Sub
   Public Function ReplaceText(ByRef app As
Microsoft.Office.Interop.Word.Application, ByVal i As Integer)

       With app.Selection.Find
           .Execute(findtext:="{Text}", _
              ReplaceWith:="")
           .Forward = True
           .Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue
       End With
   End Function

> Hello All,
>
[quoted text clipped - 11 lines]
>
> Thanks!
 
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.