I have a project that was created by another developer and it's my task to fix it as it isn't working properly.
There are users running an application to process medical claims. If there's anything that doesn't seem right, they are to generate a correspondence letter requesting further information. This is done by the application by selecting the state patient/provider are in and the type of correspondence needed. Because there are so many letters, a macro was built to speed up the process.
Since the creation of the macro, it has been determined that the macro still has some issues that were never resolved, and a third party vendor that receives the letters and mails them out stated the date and address of the provider do not correctly fit the window of the envelope. This is where I come in.
Here is what the letter looks like:
The top address block for the insurance company needs to move down just enough for a bar code to be added (not sure how to add a bar code...maybe a font?). The date and address for Jane Doe needs to be moved down also so they can be clearly seen through the clear plastic window of a billing envelope.
The current code copies the template and pastes it into a new Word doc so it can be edited. It does move things, but it also deletes "Plan of Texas" at the top, doesn't create a bar code, and doesn't move the date and other address down enough to where they can be fully viewed. Any advice will be greatly appreciated.
Here's the current code I need to modify:
[pre]Option Explicit
Dim objWrd, strPath, objDoc
Dim strFl, State, FirstWord, p, x, chkMsg
strPath = "%MyDoc%\SF Letters\"
strFl = strPath & "%sfid%" & ".docx"
Set objWrd = GetObject(, "Word.Application")
Set objDoc = objWrd.Documents.Add
objWrd.Visible = True
' Pastes copy of original letter template
objWrd.Selection.PasteAndFormat (16) 'wdFormatOriginalFormatting
objWrd.Selection.HomeKey 6, 0
objDoc.Revisions.RejectAll
objWrd.Selection.HomeKey 6, 0
objWrd.Selection.Find.MatchWholeWord = True
objWrd.Selection.Find.Text = "Plan of "
objWrd.Selection.Find.Execute
objWrd.Selection.EndKey , 20
x = objWrd.Selection
If InStr(x, "Plan of ") > 0 Then
objWrd.Selection.HomeKey 6, 0
objWrd.Selection.Find.MatchWholeWord = True
objWrd.Selection.Find.Text = x
objWrd.Selection.Find.Execute , , , , , , , , , "Plan"
objWrd.Selection.MoveRight 1, 1
objWrd.Selection.InsertAfter vbNewLine
objWrd.Selection.MoveRight 1, 1
End If
For Each p In objDoc.Paragraphs
If Trim(Replace(p.Range.Text, Chr(13), "")) <> "" Then
FirstWord = p.Range.Text
objWrd.Selection.HomeKey 6, 0
objWrd.Selection.Find.MatchWholeWord = True
objWrd.Selection.Find.Text = FirstWord
objWrd.Selection.Find.Execute
objWrd.Selection.InsertBefore vbNewLine
objWrd.Selection.InsertBefore vbNewLine
Exit For
End If
Next
objWrd.Selection.MoveLeft 1, 1
objWrd.Activate
objWrd.Activate
chkMsg = MsgBox("Please check the letter, if it is correct?" & vbNewLine & vbNewLine & "Press OK to save the letter.", vbOKCancel + vbSystemModal, "Verify Document!!")
If chkMsg = vbOK Then
objDoc.SaveAs (strFl)
objWrd.Quit
End If
Set objDoc = Nothing
Set objWrd = Nothing[/pre]
There are users running an application to process medical claims. If there's anything that doesn't seem right, they are to generate a correspondence letter requesting further information. This is done by the application by selecting the state patient/provider are in and the type of correspondence needed. Because there are so many letters, a macro was built to speed up the process.
Since the creation of the macro, it has been determined that the macro still has some issues that were never resolved, and a third party vendor that receives the letters and mails them out stated the date and address of the provider do not correctly fit the window of the envelope. This is where I come in.
Here is what the letter looks like:
The top address block for the insurance company needs to move down just enough for a bar code to be added (not sure how to add a bar code...maybe a font?). The date and address for Jane Doe needs to be moved down also so they can be clearly seen through the clear plastic window of a billing envelope.
The current code copies the template and pastes it into a new Word doc so it can be edited. It does move things, but it also deletes "Plan of Texas" at the top, doesn't create a bar code, and doesn't move the date and other address down enough to where they can be fully viewed. Any advice will be greatly appreciated.
Here's the current code I need to modify:
[pre]Option Explicit
Dim objWrd, strPath, objDoc
Dim strFl, State, FirstWord, p, x, chkMsg
strPath = "%MyDoc%\SF Letters\"
strFl = strPath & "%sfid%" & ".docx"
Set objWrd = GetObject(, "Word.Application")
Set objDoc = objWrd.Documents.Add
objWrd.Visible = True
' Pastes copy of original letter template
objWrd.Selection.PasteAndFormat (16) 'wdFormatOriginalFormatting
objWrd.Selection.HomeKey 6, 0
objDoc.Revisions.RejectAll
objWrd.Selection.HomeKey 6, 0
objWrd.Selection.Find.MatchWholeWord = True
objWrd.Selection.Find.Text = "Plan of "
objWrd.Selection.Find.Execute
objWrd.Selection.EndKey , 20
x = objWrd.Selection
If InStr(x, "Plan of ") > 0 Then
objWrd.Selection.HomeKey 6, 0
objWrd.Selection.Find.MatchWholeWord = True
objWrd.Selection.Find.Text = x
objWrd.Selection.Find.Execute , , , , , , , , , "Plan"
objWrd.Selection.MoveRight 1, 1
objWrd.Selection.InsertAfter vbNewLine
objWrd.Selection.MoveRight 1, 1
End If
For Each p In objDoc.Paragraphs
If Trim(Replace(p.Range.Text, Chr(13), "")) <> "" Then
FirstWord = p.Range.Text
objWrd.Selection.HomeKey 6, 0
objWrd.Selection.Find.MatchWholeWord = True
objWrd.Selection.Find.Text = FirstWord
objWrd.Selection.Find.Execute
objWrd.Selection.InsertBefore vbNewLine
objWrd.Selection.InsertBefore vbNewLine
Exit For
End If
Next
objWrd.Selection.MoveLeft 1, 1
objWrd.Activate
objWrd.Activate
chkMsg = MsgBox("Please check the letter, if it is correct?" & vbNewLine & vbNewLine & "Press OK to save the letter.", vbOKCancel + vbSystemModal, "Verify Document!!")
If chkMsg = vbOK Then
objDoc.SaveAs (strFl)
objWrd.Quit
End If
Set objDoc = Nothing
Set objWrd = Nothing[/pre]