Hello All,
I've been doing research online and be hearing about early binding vs late binding. I'm currently working on a log that will be used by multiple people who i won't be able to set references too and who will probably be using different versions of excel. I feel that late binding might be the solution, unless someone know something better because i'm more use to early binding as it would appears. Anyways i have the following code and wanted to see if anyone could help me convert it to late binding. Hopefully i could then use this as a starting point to figuring how to use Late Binding for the rest of my project.
I've been doing research online and be hearing about early binding vs late binding. I'm currently working on a log that will be used by multiple people who i won't be able to set references too and who will probably be using different versions of excel. I feel that late binding might be the solution, unless someone know something better because i'm more use to early binding as it would appears. Anyways i have the following code and wanted to see if anyone could help me convert it to late binding. Hopefully i could then use this as a starting point to figuring how to use Late Binding for the rest of my project.
VBA Code:
Sub PerfCashMemoTP(rw As Long)
Application.EnableEvents = False
Dim TPws As Worksheet, CONws As Worksheet, SECws As Workbook, Datws As Worksheet
Dim Wordapp As Word.Application
Dim Location As Variant
Dim lrow As Long
Dim TPdate As Long, Tech As String, TechR As Long, Cash As Long
Set TPws = ThisWorkbook.Worksheets("Tract Parcels")
Set CONws = ThisWorkbook.Worksheets("Contact")
Set SECws = ThisWorkbook.Worksheets("Security")
Set Datws = ThisWorkbook.Worksheets("DATA")
Set Wordapp = CreateObject("Word.Application")
Dim wFile As String
wFile = ActiveWorkbook.Path & "\Release Letters\Perf CASH RELEASE MEMO"
If Dir(wFile) <> "" Then
Wordapp.Documents.Open (wFile)
Wordapp.Visible = True
Else
MsgBox "File does not exists"
GoTo Finaled:
End If
Wordapp.ActiveDocument.FormFields("TXDate").Result = Format(Now(), "mmmm dd, yyyy")
Select Case TPws.Cells(rw, "G")
Case Is < 10000
Select Case TPws.Cells(rw, "H")
Case Empty, "", "N/A"
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Tract " & TPws.Cells(rw, "G").Value & " " & TPws.Cells(rw, "H").Value & " " & TPws.Cells(rw, "I").Value
Case Else
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Tract " & TPws.Cells(rw, "G").Value
End Select
Case Else
Select Case TPws.Cells(rw, "H")
Case Empty, "", "N/A"
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Parcel Map " & TPws.Cells(rw, "G").Value & " " & TPws.Cells(rw, "H").Value & " " & TPws.Cells(rw, "I").Value
Case Else
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Parcel Map " & TPws.Cells(rw, "G").Value
End Select
End Select
Select Case TPws.Cells(rw, "D")
Case "IMP AGR"
Wordapp.ActiveDocument.FormFields("TXNum").Result = "Improvement Agreement # " & TPws.Cells(rw, "E").Value
Wordapp.ActiveDocument.FormFields("TXNum1").Result = "Improvement Agreement # " & TPws.Cells(rw, "E").Value
Case "PVT AGR"
Wordapp.ActiveDocument.FormFields("TXNum").Result = "Private Improvement Agreement # " & TPws.Cells(rw, "E").Value
Wordapp.ActiveDocument.FormFields("TXNum1").Result = "Private Improvement Agreement # " & TPws.Cells(rw, "E").Value
End Select
Wordapp.ActiveDocument.FormFields("TXDeveloper").Result = TPws.Cells(rw, "AV").Value
Wordapp.ActiveDocument.FormFields("TXDeveloper1").Result = TPws.Cells(rw, "AV").Value
Wordapp.ActiveDocument.FormFields("TXDeveloper2").Result = TPws.Cells(rw, "AV").Value
Wordapp.ActiveDocument.FormFields("TXOrgAmount").Result = Format(TPws.Cells(rw, "P").Value, "Currency")
Wordapp.ActiveDocument.FormFields("TXOrgAmount1").Result = Format(TPws.Cells(rw, "P").Value, "Currency")
Wordapp.ActiveDocument.FormFields("TXDeveloper").Result = Format(TPws.Cells(rw, "AY").Value, "mmmm dd, yyyy")
Wordapp.ActiveDocument.FormFields("TXReceiptNum").Result = TPws.Cells(rw, "AZ").Value
Wordapp.ActiveDocument.FormFields("TXNOCDate").Result = Format(TPws.Cells(rw, "AB").Value, "mmmm dd, yyyy")
Cash = TPws.Cells(rw, "S").Value
Wordapp.ActiveDocument.FormFields("TXAmountReturned").Result = Format(TPws.Cells(rw, "P").Value - Cash, "Currency")
Wordapp.ActiveDocument.FormFields("TXAmountReturned1").Result = Format(TPws.Cells(rw, "P").Value - Cash, "Currency")
COntactPerf = TPContFD(rw)
Wordapp.ActiveDocument.FormFields("TXAddress").Result = CONws.Cells(COntactPerf, "G").Value ' Addresss
Wordapp.ActiveDocument.FormFields("TXCSZ").Result = CONws.Cells(COntactPerf, "H").Value & ", " & CONws.Cells(COntactPerf, "I").Value & " " & CONws.Cells(COntactPerf, "J").Value 'City, State, Zip Entry
Wordapp.ActiveDocument.FormFields("TXBondLOC").Result = TPws.Cells(rw, "M").Value
Wordapp.ActiveDocument.FormFields("TXLMAmount").Result = Format(TPws.Cells(rw, "S").Value, "Currency")
Wordapp.ActiveDocument.FormFields("TXTech").Result = TPws.Cells(rw, "B").Value
MsgBox ("Please review Performance Memo before release.")
Finaled:
Application.EnableEvents = True
End Sub