Solved

Word Automation inside Access (VBA) - does Word version matter?

Posted on 2003-10-23
7
732 Views
Last Modified: 2012-06-21
This took a few minutes to hunt down, since it didn't happen on MY machine but was happening on someone else's machine.  I have a theory as to why, but not sure that the solution will end up being.


The following line:

objWord1.ActiveDocument.Tables(1).Borders(wdBorderHorizontal).LineWidth = wdLineWidth050pt

Works fine under Word 2000 (Windows 2000 Pro)

causes an execution error under Word 2002 (XP)

Is there a work-around for this?


Thank you,

Tom


~~~~~~~~~~~~~~~~~~~

Here is the entire Form source code (if it helps)


Option Compare Database

Function fnGetDealList(strTempLenderPhone As String) As String
    Set recTemp2 = New Recordset
    Dim strClients2 As String
   
    Dim strMonth As String
    Dim strYear As String

    recTemp2.CursorLocation = adUseClient
   
    strClients2 = ""
   
    'Pre Lender Normalization
    'recTemp2.Open "select tblEntries.EntryID, tblEntries.Buyer, tblEntries.SellerAddress, tblEntries.SellerCity, tblEntries.Funded, tblEntries.Lender, tblEntries.LenderPhone, tblEntries.LO FROM tblEntries WHERE Month(tblEntries.Funded) = '" & intLetterMonth & "' AND Year(tblEntries.Funded) = '" & intLetterYear & "' AND [LenderPhone] = '" & strTempLenderPhone & "'", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
   
    'Post Lender Normalization - 9 April, 2003
    recTemp2.Open "select entryLenderView.EntryID, entryLenderView.Buyer, entryLenderView.SellerAddress, entryLenderView.SellerCity, entryLenderView.Funded, entryLenderView.company as Lender, entryLenderView.workNumber as LenderPhone, entryLenderView.lonameName as LO FROM entryLenderView WHERE Month(entryLenderView.Funded) = '" & intLetterMonth & "' AND Year(entryLenderView.Funded) = '" & intLetterYear & "' AND entryLenderView.workNumnber = '" & strTempLenderPhone & "'", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
   
    strClients2 = "ID#=Buyer=Property Address=Loan Officer=Funded        Date" & Chr(10)
   
    Do While recTemp2.EOF = False
        If recTemp2.Fields("LenderPhone").Value = strTempLenderPhone Then
            strClients2 = strClients2 & recTemp2("EntryID") & "=" & recTemp2("Buyer") & "=" & recTemp2("SellerAddress") & IIf(Nz(recTemp2("SellerAddress"), "") = "", "", ", ") & recTemp2("SellerCity") & "=" & recTemp2("LO") & "=" & Format(recTemp2("Funded"), "m/d/yyyy") & Chr(10)
        End If
        recTemp2.MoveNext
    Loop
   
    Set recTemp2 = Nothing
   
    fnGetDealList = strClients2
   
End Function

Private Sub cmbMonthYear_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[LOLetterID] = " & str(Me![cmbMonthYear])
    Me.Bookmark = rs.Bookmark
End Sub

Private Sub cmdPrintLenderDealLetters_Click()
    MsgBox "Before Lender Deals Letters Sub"
    sbPrintLODeals
    MsgBox "After Lender Deals Letters Sub"
   
 '   MsgBox "This functionality is offline until further notice.  These letters are currently being sent out manually."
End Sub

Function ConvertRawPhone(RawPhone As String) As String
Select Case Len(RawPhone)
    Case 7
        ConvertRawPhone = Left(RawPhone, 3) & "-" & Mid(RawPhone, 4, 4)
    Case 10
        ConvertRawPhone = "(" & Left(RawPhone, 3) & ") " & Mid(RawPhone, 4, 3) & "-" & Mid(RawPhone, 7, 4)
    Case Else
End Select
End Function

Private Sub cmdOpenLenderLetterInfoForm_Click()
On Error GoTo Err_cmdOpenLenderLetterInfoForm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmLenderLetterInfo"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenLenderLetterInfoForm_Click:
    Exit Sub

Err_cmdOpenLenderLetterInfoForm_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenLenderLetterInfoForm_Click
   
End Sub

Private Sub Form_Load()
    Dim strTempDate As String
   
    Label11.Caption = "Count: --/--"
    chkVerify = True
    Me.cmbMonthYear.SetFocus
    If (Month(Date) > 1) Then
        strTempDate = Month(Date) - 1 & "/1/" & Year(Date)
        Me.cmbMonthYear.Text = Format(strTempDate, "mmmm") & " " & Year(Date)
    Else
        Me.cmbMonthYear.Text = "December " & Year(Date) - 1
    End If
   
    If fnGetNetworkUserName = "tom" Or fnGetNetworkUserName = "jasons" Then
        Me.chkForceSpanishLetter.Visible = True
    Else
        Me.chkForceSpanishLetter.Visible = False
    End If
   
End Sub

Function fnListLODealsForLenderLetter(strTempPhone As String, intMonth, intYear) As String
    Dim recTemp As Recordset
    Set recTemp = New Recordset
    Dim strClients() As String
    Dim strClientList As String
    Dim strTempQuery As String
    Dim intRecCount As Long
    Dim intPosLastComma As Long
    Dim intCounter As Long
   
    Dim strTempDeal As String
       
    'Pre Lender Normalization
    'strTempQuery = "SELECT tblEntries.LO FROM tblEntries WHERE tblEntries.LenderPhone = '" & strTempPhone & "' GROUP BY tblEntries.LO;"
   
    'Post Lender Normalization - 9 April, 2003
    strTempQuery = "SELECT entryLenderView.lonameName as LO FROM entryLenderView WHERE entryLenderView.companyPhone = '" & strTempPhone & "' GROUP BY entryLenderView.lonameName;"
   
    recTemp.CursorLocation = adUseClient
   
    recTemp.Open strTempQuery, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
   
    intRecCount = recTemp.RecordCount
   
    intCounter = 1
   
    If intRecCount > 0 Then
   
        ReDim strClients(1 To intRecCount)
       
        Do While recTemp.EOF = False
                strClients(intCounter) = Trim(Nz(recTemp("LO"), ""))
                If strClients(intCounter) <> "" Then
                    strTempDeal = fnGetDealListForLO(strTempPhone, strClients(intCounter), (intMonth), (intYear))
                    intCounter = intCounter + 1
                End If
                recTemp.MoveNext
        Loop
           
           
        If intRecCount = 1 Then
            If strClients(1) <> "" Then
                strClientList = strClients(1) & "."
            End If
        End If
       
        If intRecCount = 2 Then
            If strClients(1) <> "" And strClients(2) <> "" Then
                strClientList = strClients(1) & " and " & strClients(2) & "."
            End If
            If strClients(1) = "" And strClients(2) <> "" Then
                strClientList = strClients(2) & "."
            End If
            If strClients(1) <> "" And strClients(2) = "" Then
                strClientList = strClients(1) & "."
            End If
            If strClients(1) = "" And strClients(2) = "" Then
                strClientList = "No contacts found."
            End If
           
        End If
       
       
        If intRecCount > 2 Then
            For i = 1 To intRecCount - 1
                strClientList = strClientList & strClients(i) & ", "
            Next i
            strClientList = strClientList & "and " & strClients(intRecCount) & "."
        End If
       
       
        Set recTemp = Nothing
    Else
        strClientList = "No Loan Officers Found"
    End If
   
    fnListLODealsForLenderLetter = strClientList
   

End Function



Function fnGetDealListForLO(strTempLenderPhone As String, strTempLO As String, intMonth As Integer, intYear As Integer) As String
    Set recTemp2 = New Recordset
    Dim strClients2 As String
   
    Dim strMonth As String
    Dim strYear As String
    Dim strTempSQL As String
       
    recTemp2.CursorLocation = adUseClient
   
    strClients2 = ""
               
    'Pre Lender Normalization
    'strTempSQL = "SELECT tblEntries.EntryID, tblEntries.Buyer, tblEntries.SellerAddress, tblEntries.SellerCity, tblEntries.Funded, tblEntries.Lender, tblEntries.LenderPhone FROM tblEntries WHERE ((tblEntries.LO = '" & strTempLO & "') AND (Month(tblEntries.Funded) = " & intMonth & ") AND (Year(tblEntries.Funded) = " & intYear & ") AND ([LenderPhone] = '" & strTempLenderPhone & "'));"
   
    'Post Lender Normalization - 9 April, 2003
    strTempSQL = "SELECT entryLenderView.EntryID, entryLenderView.Buyer, entryLenderView.SellerAddress, entryLenderView.SellerCity, entryLenderView.Funded, entryLenderView.Lender, entryLenderView.LenderPhone FROM entryLenderView WHERE ((entryLenderView.loname = '" & strTempLO & "') AND (Month(entryLenderView.Funded) = " & intMonth & ") AND (Year(entryLenderView.Funded) = " & intYear & ") AND (entryLenderView.LenderPhone = '" & strTempLenderPhone & "'));"

    recTemp2.Open strTempSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
   
    strClients2 = "ID#=Buyer=Property Address=Funded        Date" & Chr(10)
   
       
    Do While recTemp2.EOF = False
        If recTemp2.Fields("LenderPhone").Value = strTempLenderPhone Then
            strClients2 = strClients2 & recTemp2("EntryID") & "=" & recTemp2("Buyer") & "=" & recTemp2("SellerAddress") & IIf(Nz(recTemp2("SellerAddress"), "") = "", "", ", ") & recTemp2("SellerCity") & "=" & Format(recTemp2("Funded"), "m/d/yyyy") & Chr(10)
        End If
        recTemp2.MoveNext
    Loop
   
    Set recTemp2 = Nothing
   
    fnGetDealListForLO = strClients2
   
End Function

Sub sbPrintLODeals()
   
    Dim strFaxOutTable As String
   
    Dim strFaxRaw As String
    Dim strToField As String
    Dim strSubject As String
    Dim strFile1 As String, strFile2 As String
    Dim fPrintOut As Boolean
    Dim strTempInText As String
    Dim strTempFieldName As String
    Dim FBoldSetting As Boolean
    Dim FItalicSetting As Boolean
    Dim FUnderlineSetting As Boolean
    Dim intFontSize As Long
    Dim intBookmarkCount As Long
    Dim strPages As Variant
    Dim strCertifiedFaxDocumentToSend As String
    Dim lngEntryID As Variant
    Dim intCounter As Long
   
    Set recTemp = New Recordset
   
    Dim strLetterName As String
    Dim intRecordCount As Long
    Dim dblOrigRandomID As Double
    Dim dblNewRandomID As Double
    Dim varRandomID As Variant
   
    Dim strFaxType As String
    Dim fGoes
    Dim strOutFile As String
    Dim strOutPath As String
    Dim strOutFile2 As String
    Dim TimeIn As Date
    Dim bk As Bookmark
    Dim intClientCount As Long
    Dim strClientList As String
    Dim strLOList As String
    Dim FSkipFieldFill As Boolean
    Dim strEntryID As String
    Dim strDefaultMessage As String
   
    Dim intLetterMonth As Integer
    Dim intLetterYear As Integer
   
    MsgBox "Inside Lender Deals Letters Sub"
    MsgBox "Inside Lender Deals Letters Sub - Just finished Dimming Vars"
   
    intLetterMonth = Month(Me.cmbMonthYear.Column(1))
    intLetterYear = Year(Me.cmbMonthYear.Column(1))
           
    intCounter = 0
   
    TimeIn = Now
   
    MsgBox "Inside Lender Deals Letters Sub - Before SQL creation"
    strFaxOutTable = "SELECT entryLenderView.loname as LO, entryLenderView.workNumber as LenderPhone, qryLenderInfoComplete.PhoneInfo, " & _
    "entryLenderView.Lender as LenderInfoName, qryLenderInfoComplete.AddressInfo, qryLenderInfoComplete.CityInfo, " & _
    "qryLenderInfoComplete.StateInfo, qryLenderInfoComplete.ZipInfo FROM entryLenderView INNER JOIN qryLenderInfoComplete " & _
    "ON entryLenderView.workNumber = qryLenderInfoComplete.PhoneInfo WHERE (entryLenderView.Status <> 'Cancelled') " & _
    "AND entryLenderView.loName <> '' AND (Month(CDate(nz(Int([Funded]),0)))=" & intLetterMonth & ") AND (Year(CDate(nz(Int([Funded]),0)))=" & intLetterYear & ") " & _
    "GROUP BY entryLenderView.loname, entryLenderView.workNumber, qryLenderInfoComplete.PhoneInfo, entryLenderView.Lender, " & _
    "qryLenderInfoComplete.AddressInfo, qryLenderInfoComplete.CityInfo, qryLenderInfoComplete.StateInfo, qryLenderInfoComplete.ZipInfo " & _
    "HAVING entryLenderView.workNumber Is Not Null;"
   
    MsgBox "Inside Lender Deals Letters Sub - After SQL creation"
       
    recTemp.CursorLocation = adUseClient
   
    recTemp.Open strFaxOutTable, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
   
    MsgBox "Inside Lender Deals Letters Sub - Just opened recordset"
    'Count of records (Lender Deal Lettes to print)
    intRecordCount = recTemp.RecordCount
   
    MsgBox "Inside Lender Deals Letters Sub - count is:  " & intRecordCount
   
    'LOOP through all records in tblFaxOutHolder
    Dim objWord1 As New Word.Application
   
    MsgBox "Inside Lender Deals Letters Sub - just dimmed new word doc object"
   
    intCounter = 0
   
    Do While recTemp.EOF = False
        MsgBox "Inside Lender Deals Letters Sub - TOP of do while not rs.EOF"
        'Lookup langID (English or Spanish)
        '28 August 2003
           
        If Nz(recTemp("StateInfo"), "") = "PR" Then
            intLangID = LangTypeSpanish
        Else
            intLangID = LangTypeEnglish
        End If
       
        MsgBox "Inside Lender Deals Letters Sub - State was:  " & recTemp("StateInfo")
       
        If Me.chkForceSpanishLetter.Visible = True Then
            If Me.chkForceSpanishLetter.Value = -1 Then
                intLangID = LangTypeSpanish
            End If
        End If
         
        'English
        If intLangID = LangTypeEnglish Then
            strCertifiedFaxDocumentToSend = "P:\Documents\LenderDeals_English.dot"
        End If
               
        'Spanish
        If intLangID = LangTypeSpanish Then
            strCertifiedFaxDocumentToSend = "P:\Documents\LenderDeals_Spanish.dot"
        End If
       
        MsgBox "Inside Lender Deals Letters Sub - letter chosen was:  " & strCertifiedFaxDocumentToSend
               
        objWord1.Documents.Add strCertifiedFaxDocumentToSend
       
       
        For Each bk In objWord1.ActiveDocument.Bookmarks
            ' if the name is the same as a bookmark name, increment counter + 1
            strTempInText = bk.Name
           
            MsgBox "Inside Lender Deals Letters Sub - bookmark is:" & strTempInText
           
            bk.Select
           
            FSkipFieldFill = False
           
            'Special Cases for bookmark
           
            If strTempInText = "message1" Then
                objWord1.Selection.Font.Bold = FBoldSetting
                objWord1.Selection.Font.Italic = FItalicSetting
                objWord1.Selection.Font.Underline = FUnderlineSetting
                objWord1.Selection.Font.Size = 11
                Dim tempStr As String
                               
                If intLangID = LangTypeEnglish Then
                    strDefaultMessage = "Neighborhood Gold is dedicated to increasing housing opportunities nationally, and is very appreciative of your assistance in aiding us accomplish this goal.  In addition, we are also dedicated to increasing your personal opportunities to grow your business.  We do this by providing you with local Account Executives to aid in driving more transactions toward you, our valued client." & Chr(10) & Chr(13) & _
                    "As one of our valued clients, your input is very important to me.  As we continue to bring one of the most innovative housing products to the market place, I would appreciate if you would email me with areas in which we can better serve you and your clients needs.  I can be reached at rich@neighborhoodgold.com"
   
                    tempStr = Nz(DLookup("LetterBody", "tblLOLetter", "Month([MonthToSend]) = " & intLetterMonth & " and Year([MonthToSend]) = " & intLetterYear), strDefaultMessage)
                Else
                    strDefaulMessage = "Neighborhood Gold está dedicado a  aumentar las oportunidades de adquirir una vivienda en todo el  país y desea agradecerle su cooperación  para alcanzar esta meta.  Además, es parte de nuestra misión ayudarle a aumentar sus oportunidades personales  para el crecimiento de su negocio. Con este fin y  por ser nuestro valioso cliente, tenemos Ejecutivos de Cuenta locales para que Ud." & _
                    "se beneficie  de un aumento en el número de transacciones." & Chr(10) & Chr(13) & _
                    "Por todas estas razones, es muy importante que sepamos su opinión. Al continuar ofreciendo  uno de los productos más innovativos en el campo de la vivienda, nos sería invaluable recibir sus sugerencias por correo electrónico para determinar de qué manera podemos servirlo mejor a Ud. y a sus clientes. Desde ya, le agradecería se pusiera en contacto conmigo a la dirección rich@neighborhoodgold.com."
                   
                    tempStr = Nz(DLookup("spanishLetterBody", "tblLOLetter", "Month([MonthToSend]) = " & intLetterMonth & " and Year([MonthToSend]) = " & intLetterYear), strDefaultMessage)
                   
                End If
               
                objWord1.Selection.TypeText tempStr


                FSkipFieldFill = True
            End If
           
            If strTempInText = "deals" Then
           
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark begin"
                               
                objWord1.Selection.Font.Bold = FBoldSetting
                objWord1.Selection.Font.Italic = FItalicSetting
                objWord1.Selection.Font.Underline = FUnderlineSetting
                objWord1.Selection.Font.Size = 12
             
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - before client list generation"
               
                strClientList = fnGetDealListForLO(recTemp.Fields("LenderPhone"), (fnPrepTextField(recTemp.Fields("LO"))), (intLetterMonth), (intLetterYear))
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - after client list generation"
               
                objWord1.Selection.InsertBefore strClientList
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - before convert string to table"
                objWord1.Selection.ConvertToTable "=", , 4, , , True, , , , , , , , False
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - after convert string to table"
               
                objWord1.ActiveDocument.Tables(1).Rows.AllowBreakAcrossPages = False
               
                objWord1.ActiveDocument.Tables(1).Rows(1).Select
   
                objWord1.Selection.Font.Bold = True
                'EntryID
                objWord1.ActiveDocument.Tables(1).Columns(1).Width = 45
                'Buyer
                objWord1.ActiveDocument.Tables(1).Columns(2).Width = 115
                'Property Address
                objWord1.ActiveDocument.Tables(1).Columns(3).Width = 120
                'Funded Date
                objWord1.ActiveDocument.Tables(1).Columns(4).Width = 60
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset table widths"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderLeft).LineWidth = wdLineWidth050pt
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderLeft).Color = wdColorAutomatic
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border LEFT styles"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderRight).LineStyle = wdLineStyleSingle
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderRight).LineWidth = wdLineWidth050pt
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderRight).Color = wdColorAutomatic
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border RIGHT styles"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderTop).LineStyle = wdLineStyleSingle
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderTop).LineWidth = wdLineWidth050pt
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderTop).Color = wdColorAutomatic
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border TOP styles"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderBottom).LineWidth = wdLineWidth050pt
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderBottom).Color = wdColorAutomatic
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border BOTTOM styles"
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - ERROR SHOULD HAPPEN IN THE NEXT THREE LINES"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset wdBorderHorizontal Line Style"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderHorizontal).LineWidth = wdLineWidth050pt
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset wdBorderHorizontal Line Width"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderHorizontal).Color = wdColorAutomatic
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset wdBorderHorizontal Line Color"
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border horizontal styles"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderVertical).LineStyle = wdLineStyleSingle
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderVertical).LineWidth = wdLineWidth050pt
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderVertical).Color = wdColorAutomatic
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border vertical styles"
               
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
                objWord1.ActiveDocument.Tables(1).Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
                objWord1.ActiveDocument.Tables(1).Borders.Shadow = False
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border diagonal styles"
               
                objWord1.Options.DefaultBorderLineStyle = wdLineStyleSingle
                objWord1.Options.DefaultBorderLineWidth = wdLineWidth050pt
                objWord1.Options.DefaultBorderColor = wdColorAutomatic
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border default styles"
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark - just reset border widths"
               
                FSkipFieldFill = True
               
                MsgBox "Inside Lender Deals Letters Sub - deals bookmark end"
            End If
           
           If FSkipFieldFill = False Then
           
                ParseBookmark strTempInText, strTempFieldName, FBoldSetting, FItalicSetting, FUnderlineSetting, intFontSize, intBookmarkCount
               
               
                Select Case Nz(recTemp.Fields(strTempFieldName).Value, "")
                    Case ""
                        objWord1.Selection.Delete
                    Case Else
                        objWord1.Selection.Font.Bold = FBoldSetting
                        objWord1.Selection.Font.Italic = FItalicSetting
                        objWord1.Selection.Font.Underline = FUnderlineSetting
                        objWord1.Selection.Font.Size = intFontSize
                       
                    If strTempFieldName = "LenderPhone" Then
                        objWord1.Selection.TypeText ConvertRawPhone(recTemp.Fields(strTempFieldName).Value)
                    ElseIf strTempFieldName = "CityInfo" Then
                        objWord1.Selection.TypeText recTemp("CityInfo") & ", " & recTemp("StateInfo") & " " & recTemp("ZipInfo")
                    Else
                        objWord1.Selection.TypeText recTemp.Fields(strTempFieldName).Value
                    End If
                End Select
            End If
            MsgBox "Inside Lender Deals Letters Sub - BOTTOM OF BOOKMARKS"
        Next
       
        MsgBox "Inside Lender Deals Letters Sub - just finished looping through bookmarks"
       
        strClientList = ""
       
        dblOrigRandomID = UniqueCode
       
        dblNewRandomID = dblOrigRandomID + 2147483648#
       
        varRandomID = dblNewRandomID
       
        strOutFile = "adv\" & varRandomID & "LenderLetter" & Month(Date) & Day(Date) & Year(Date) & ".doc"
        strOutPath = "K:\coverpge\"
        strFile1 = strOutPath & strOutFile
       
        objWord1.ActiveDocument.SaveAs strFile1
       
       
        'If recTemp.Fields("AddressInfo").Value = "923 South River Rd. Suite 211" Then
        '    objWord1.PrintOut
        'End If
                       
        'If recTemp.Fields("AddressInfo").Value = "1854 Loxley Rd." Then
        '    objWord1.PrintOut
        'End If
                       
        MsgBox "Inside Lender Deals Letters Sub - before printing"
       
        objWord1.PrintOut
       
        MsgBox "Inside Lender Deals Letters Sub - after printing"
       
        DoEvents
       
        objWord1.ActiveDocument.Close
             
        DoEvents
       
           
        Label11.Caption = "Count:  " & intCounter & " / " & recTemp.RecordCount
       
        If chkVerify = True Then
            If MsgBox("Check the letter you just printed for formatting issues (fits properly in the windowed envelope).  If everything looks good, click YES to print the rest of the letters, or No to cancel printing all letters.", vbYesNo + vbDefaultButton2) = vbNo Then
                objWord1.Quit
                Set objWord1 = Nothing
                Set recTemp = Nothing
                MsgBox intCounter & " Lender Letters printed."
                Exit Sub
            End If
    End If
        recTemp.MoveNext
        chkVerify = False
        DoEvents
        intCounter = intCounter + 1
       
        MsgBox "Inside Lender Deals Letters Sub - before Loop"
    Loop
   
    MsgBox "Inside Lender Deals Letters Sub - exited Loop"
    objWord1.Quit
    Set objWord1 = Nothing
   
    Set recTemp = Nothing

   
    MsgBox intCounter & " Lender Letters printed."

   
End Sub

Function fnPrepTextField(strTemp As String) As String
    Dim strTempStrCleaned As String
   
    strTempStrCleaned = TextCleaner(strTemp, "'")
   
    fnPrepTextField = strTempStrCleaned
   
End Function
0
Comment
Question by:knowlton
7 Comments
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
Hey knowlton!

  >>objWord1.ActiveDocument.Tables(1).Borders(wdBorderHorizontal).LineWidth = wdLineWidth050pt
 
  try doing this without the activedocument ref.
  objWord1.Documents(1).Tables(1).Borders(wdBorderHorizontal).LineWidth = wdLineWidth050pt

  and make sure the word version you are writing to accepts/understands the "wdLineWidth050pt" system constant.

regards
Jack
0
 
LVL 17

Expert Comment

by:smozgur
Comment Utility
I agree with Jack about wdLineWidth050pt.

I would use 4 instead.

Suat
0
 
LVL 16

Expert Comment

by:ahmedbahgat
Comment Utility
also make sure to check the refrences under the xp machine, and possibly remove and add word liberary

cheers
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 5

Author Comment

by:knowlton
Comment Utility
objWord1.Documents(1).Tables(1).Borders(wdBorderHorizontal).LineWidth = wdLineWidth050pt

did not work.  :(

objWord1.Documents(1).Tables(1).Borders(wdBorderHorizontal).LineWidth = 4

did not work.  :(

objWord1.ActiveDocument.Documents(1).Tables(1).Borders(wdBorderHorizontal).LineWidth = 4

did not work.  :(

Any other idears?
0
 
LVL 17

Expert Comment

by:smozgur
Comment Utility
What about changing also:

wdBorderVertical to  -6
wdBorderHorizontal to  -5

Suat
0
 
LVL 32

Accepted Solution

by:
jadedata earned 500 total points
Comment Utility
Sometimes with object collections like
 .Documents(1).

you can use the name
 .Documents("StateOfTheUnionAddress").

to qualify it

Activedocument takes the place of Document()

0
 
LVL 11

Expert Comment

by:Steiner
Comment Utility
Could it be the early binding of the library?
Try declaring all word-objects as object instead of Word.Application and so on. Then remove all word-constants (like wdBorderHorizontal) and replace them with their values. As a last, remove the reference to the Word-Object-Library from your project.
Now instead of using the Word 2000 library on Word XP (which might cause the problem) your project should now pick the available Word library instead.
Might be some work (especially replacing the constants) but if nothing else works, you might consider trying it.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now