Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ugent Need to Scan word document in vb.Net for word merge

Status
Not open for further replies.

RDC

Programmer
Jan 6, 2001
55
US
Please Help.. Ugent Need to make a document ACTIVE.. then SCAN it .. It was a previous HTML doc that I cut and paste into notepad to remove formatting and then saved it as a XP Word document.. In vb.Net .. i.e. need to find..
th 4% in this word document.. I HAVE SO MANY ERRORS.. IT DOESN'T SHOW THEM ALL.. I AM IN A PANIC..making it WORSE as I go.. THIS IS DUE TOMORROW MORNING.. CAN ANYONE HELP???
I know I'm importing way too much or too little..

In code, I need to
First find: USMin,
2nd find: Funding interest rate
3rd find: 4.00%

which originally came from a table looking like this in word.. then HTML..

Baseline Gain or Lower Interest Rate

Loss
1. Funding interest rate 8.00% 4.00%

here's the word document's resource code I developed from HTML.. now in a plain word.doc ...

><a name=&quot;USMin&quot;></a>
<p class=MsoNormal align=center style='text-align:center'><span
style='mso-bookmark:USMin'><o:p> </o:p></span></p>
</td>
<span style='mso-bookmark:USMin'></span>
<td valign=bottom style='border:solid windowtext 1.0pt;border-left:none;
mso-border-left-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal align=center style='text-align:center'><span
style='mso-bookmark:USMin'>Baseline Gain or </span></p>
<p class=MsoNormal align=center style='text-align:center'><span
style='mso-bookmark:USMin'>Loss</span></p>
</td>
<span style='mso-bookmark:USMin'></span>
<td valign=bottom style='border:solid windowtext 1.0pt;border-left:none;
mso-border-left-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal align=center style='text-align:center'><span
style='mso-bookmark:SMin'>Lower Interest Rate</span></p>
</td>
<span style='mso-bookmark:USMin'></span>
</tr>
<tr style='mso-yfti-irow:1'>
<td valign=bottom style='border-top:none;border-left:solid windowtext 1.0pt;
border-bottom:none;border-right:solid windowtext 1.0pt;mso-border-top-alt:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;padding:
0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal><span style='mso-bookmark:proVal_USMin'>1.<span
style='mso-tab-count:1'> </span>Funding interest rate</span></p>
</td>
<span style='mso-bookmark:USMin'></span>
<td valign=bottom style='border:none;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-right-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal align=right style='text-align:right'><span
style='mso-bookmark:USMin'>8.00%</span></p>
</td>
<span style='mso-bookmark:USMin'></span>
<td valign=bottom style='border:none;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-right-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal align=right style='text-align:right'><span
style='mso-bookmark:USMin'>4.00%</span></p>
</td>


Here's my my problem in vb.NET.. as I TRY and FAIL over and over in may attempts to scan this word document in vb.Net for word merge to pik up.. ie. the 4%


Option Strict Off
Option Explicit Off

Imports EnvDTE
Imports Word
Imports System
Imports System.Object
Imports System.Activator
Imports System.Diagnostics
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft
Imports Microsoft.Office
Imports Microsoft.Office.Core
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.ControlChars
Imports Microsoft.VisualBasic.Vsa.VsaItem
Imports OFFPROVLib10
Imports VSLangProj
Imports VsMacroHierarchyLib
Imports System.ComponentModel

Module basLD5
Public ParamArr() As String
Public previousSelection As String
Public completionWords As String
Public completionWordsIndex As Integer

Public Doc As New ..ERRRRRORS OUT

Sub Main()
Load(frmLD5)
frmLD5.SHOWDIALOG()
End Sub

Sub DocumentMacro(ByVal WordMerge As String)

Dim sel As Word.Field
Dim objWord As Word.Application
objWord = ActiveDocument().Selection

Dim searchString As String
searchString = WordField

Dim firstTime As Boolean
firstTime = True

Dim firstLine, firstCol As Integer
objWord.StartOfDocument()

previousSelection = WordMerge
completionWords = &quot; &quot;
completionWordsIndex = 2

Do While objWord.ActiveDocument.Merge(searchString)
If firstTime Then
firstLine = sel.TopLine
firstCol = sel.CurrentColumn
firstTime = False
ElseIf firstLine = sel.TopLine And firstCol = sel.CurrentColumn Then
Exit Do
End If
sel.WordRight()
sel.WordLeft(DsMovementOptions.dsExtend)
DocumentMacro(Trim(sel.Text))
sel.Cancel()
Loop

For Each doc In DTE.Documents()
doc.PrintOut()
Next

End Sub

End Module

Public Class Form1
Inherits System.Windows.Forms.Form

#Region &quot; Windows Form Designer generated code &quot;

Public Sub New()
MyBase.New()
Me.Name = &quot;frmGetMacro&quot;
Me.Text = &quot;FindMacro&quot;
Me.ResumeLayout(False)
End Sub

Friend WithEvents cboGetMacro As System.Windows.Forms.ComboBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnGetMacro As System.Windows.Forms.Button


End Sub


Private Sub btnGetMacro_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMacro.Click

''''''''''Load document.
Doc.Load(&quot;..\ActiveDocName.doc&quot;)
Mergefield = &quot;result of USMin,Funding InterestRate,LowerInterestRate.. s/be 4%&quot;

Call DocumentMacro(Mergefield)
End Sub


End Class


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top