stnkyminky
Programmer
The word document has the following "place markers" in the document
FirstName LastName
Company
Address1
Address2
Address3
Address4
City, State ZipCode
Country
I am using the two functions below to replace the markers with information from a database.
ex. reppara "FirstName", "Scott", objword
would replace FirstName with Scott.
Here is where the problem begins. If the value replacing the marker is null, I want to delete the marker and move on to the next marker. Example...Not all addresses will have 2,3 or 4 lines.
Instead of displaying something like (which the functions currently do)
Scott X
Some Company
100 Main St.
<--Address 2, 3, 4 will be blank
SomeTown, XX 55555
I want to display the following:
Scott X
Some Company
100 Main St.
SomeTown, XX 55555
Thanks for your help.
Public Sub DelPara(Header As String, Keep As Boolean, objword As Word.Application)
With objword.Selection.Find
.ClearFormatting
.Text = Header
.Execute Forward:=True
End With
Call objword.Selection.Delete
If Keep = False Then
'objword.Selection.MoveDown(wdLine, 1, wdExtend)
'Call objword.Selection.Move(wdCharacter, -1)
Call objword.Selection.MoveEnd(wdLine, 0)
End If
End Sub
Public Sub RepPara(Header As String, Data As String, objword As Word.Application)
If Len(Trim(Data)) = 0 Then
DelPara Header, False, objword
Exit Sub
End If
With objword.Selection.Find
.ClearFormatting
'.Highlight = True
.Text = Header
.Execute Forward:=True
End With
Clipboard.Clear
If IsNumeric(Data) Then
' If Data < 2.75 Then
' objword.Selection.Font.Color = wdColorRed
' End If
Clipboard.SetText (Format(Data, "0.00")
Else
Clipboard.SetText (Data)
End If
objword.Selection.Paste
Clipboard.Clear
End Sub
Scott
Programmer Analyst
<><
FirstName LastName
Company
Address1
Address2
Address3
Address4
City, State ZipCode
Country
I am using the two functions below to replace the markers with information from a database.
ex. reppara "FirstName", "Scott", objword
would replace FirstName with Scott.
Here is where the problem begins. If the value replacing the marker is null, I want to delete the marker and move on to the next marker. Example...Not all addresses will have 2,3 or 4 lines.
Instead of displaying something like (which the functions currently do)
Scott X
Some Company
100 Main St.
<--Address 2, 3, 4 will be blank
SomeTown, XX 55555
I want to display the following:
Scott X
Some Company
100 Main St.
SomeTown, XX 55555
Thanks for your help.
Public Sub DelPara(Header As String, Keep As Boolean, objword As Word.Application)
With objword.Selection.Find
.ClearFormatting
.Text = Header
.Execute Forward:=True
End With
Call objword.Selection.Delete
If Keep = False Then
'objword.Selection.MoveDown(wdLine, 1, wdExtend)
'Call objword.Selection.Move(wdCharacter, -1)
Call objword.Selection.MoveEnd(wdLine, 0)
End If
End Sub
Public Sub RepPara(Header As String, Data As String, objword As Word.Application)
If Len(Trim(Data)) = 0 Then
DelPara Header, False, objword
Exit Sub
End If
With objword.Selection.Find
.ClearFormatting
'.Highlight = True
.Text = Header
.Execute Forward:=True
End With
Clipboard.Clear
If IsNumeric(Data) Then
' If Data < 2.75 Then
' objword.Selection.Font.Color = wdColorRed
' End If
Clipboard.SetText (Format(Data, "0.00")
Else
Clipboard.SetText (Data)
End If
objword.Selection.Paste
Clipboard.Clear
End Sub
Scott
Programmer Analyst
<><