Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 KB | None | 0 0
  1. **'Private Sub Userform_Initialize()
  2. 'add Title Options to Title list and Pension Factor lists on document open
  3. ' optGreeting1.Value = True
  4. ' With CboTitle
  5. ' .AddItem "Mr"
  6. ' .AddItem "Mrs"
  7. ' .AddItem "Ms"
  8. ' .AddItem "Miss"
  9. ' .AddItem "Doctor"
  10. ' .AddItem "Master"
  11. ' End With
  12. ' With LstbxPenFact
  13. ' .AddItem "<6 4"
  14. ' .AddItem "65-74 5"
  15. ' .AddItem "75-84 6"
  16. ' .AddItem "85-94 7"
  17. ' .AddItem "95+ 14"
  18. ' End With
  19. 'End Sub
  20. Private Sub CalculateTotalincome()
  21. Dim TxtTotalIncome As Long
  22. Set TotalIncome = Me.TxtIncome.Value
  23. TxtTotalIncome = (Me.TxtCentrelink.Value + Me.txtwages.Value + Me.TxtRent.Value +
  24. Me.TextComSuper.Value + Me.TxtotherInc.Value)
  25. End Sub
  26. Private Sub CalculateTotalExpenses()
  27. Dim TxtTotalExpenses As Long
  28. Set TotalExpenses = Me.TxtExpenses.Value
  29. TxtTotalExpenses = (Me.TxtBudget.Value + Me.TxtCapex.Value)
  30. End Sub
  31.  
  32. Private Sub CboTitle_Change()
  33.  
  34. End Sub
  35.  
  36. 'Clear data in userform
  37. Unload Me
  38. ActiveDocument.Close SaveChanges:=False
  39. End Sub
  40. Private Sub Age_Click()
  41. Dim TxtAge As Range
  42. Set Me.TxtAge = Date - Me.TxtDOB
  43. ' Calculate age as Today's date - The Clients Birthdate.
  44. dtmDate = Date
  45. dhAge = DateDiff("yyyy", dtmBD, dtmDate) + (dtmDate < DateSerial(Year(dtmDate), Month (dtmBD), Day(dtmBD)))
  46. End Sub
  47. Private Sub CmdAle_Click()
  48. 'Vlookup Average lifeexpectancy tables in excel table
  49. Dim EndorsebudWS As String
  50. Set EndorsebudWS = "S:WorkgroupWorksheets[Endorsebud.xlsx]"
  51. Me.TxtAle.Value = "=VLOOKUP(,A4'" & FileName1 & "LE'!$A"
  52. Range1 = Endorsebud.Sheets(LE).Range("A4:C113")
  53. myValue = Application.WorksheetFunction.VLookup("Ale", Range1, 2, False)
  54. End Sub
  55. Private Sub CmdTAGFees_Click()
  56. 'Calculate 1.1% of Financial Investments
  57. Dim TxtInvestments As Long
  58. Dim TxtTagFees As Long
  59. Set ClientAssets = Me.TxtInvestments.Value
  60. TxtTagFees = ClientAssets * 1.1 / 100
  61. End Sub
  62. Private Sub CmdSubmit_Click()
  63. 'replace bookmarks with userform values
  64. Dim Title As Range
  65. Set Title = ActiveDocument.Bookmarks("title").Range
  66. Title Text = Me.CboTitl.Value
  67. Dim ClientName As Range
  68. Set ClientName = ActiveDocument.Bookmarks("ClientName").Range
  69. ClientName Text = Me.TxtClientName.Value
  70. Dim ClientNumber As Range
  71. Set ClientNumber = ActiveDocument.Bookmarks("ClientNumber").Range
  72. ClientNumber Text = Me.TxtClientNumber.Value
  73. Dim ClientNumber2 As Range
  74. Set ClientNumber2 = ActiveDocument.Bookmarks("ClientNumber2").Range
  75. ClientNumber2 Text = Me.TxtClientNumber.Value
  76. Dim Age As Range
  77. Set Age = ActiveDocument.Bookmarks("Age").Range
  78. Age Text = Me.TxtAge.Value
  79. Dim DoB As Range
  80. Set DoB = ActiveDocument.Bookmarks("DoB").Range
  81. DoB Text = Me.TxtDOB.Value
  82. Dim Ale As Range
  83. Set Ale = ActiveDocument.Bookmarks("Ale").Range
  84. Ale Text = Me.TxtAle.Value
  85. Dim FmoDate As Range
  86. Set FmoDate = ActiveDocument.Bookmarks("FmoDate").Range
  87. FmoDate Text = Me.TxtFmoDate.Value
  88. Dim TotlAssets As Range
  89. Set TotalAssets = ActiveDocument.Bookmarks("TotlAssets").Range
  90. TotAssets Text = Me.TxtInvestments.Value
  91. Dim TotlAssets2 As Range
  92. Set TotalAssets2 = ActiveDocument.Bookmarks("TotlAssets").Range
  93. TotAssets2 Text = Me.TxtInvestments.Value
  94. Dim InvestmentAssets As Range
  95. Set InvestmentAssets = ActiveDocument.Bookmarks("InvestmentAssets").Range
  96. InvestmentAssets Text = Me.TxtInvestments.Value
  97. Dim TrustAccount As Range
  98. Set TrustAccount = ActiveDocument.Bookmarks("TrustAccount").Range
  99. TrustAccount Text = Me.TxtTrustAc.Value
  100. Dim TrustAccount2 As Range
  101. Set TrustAccount2 = ActiveDocument.Bookmarks("TrustAccount2").Range
  102. TrustAccount2 Text = Me.TxtTrustAc.Value
  103. Dim LastYearsExpenses As Range
  104. Set LastYearsExpenses = ActiveDocument.Bookmarks("LastYearsExpenses").Range
  105. LastYearsExpenses Text = Me.TxtPriorex.Value
  106. Dim PriorBudget As Range
  107. Set PriorBudget = ActiveDocument.Bookmarks("PriorBudget").Range
  108. PriorBudget Text = Me.txtPriorBudg.Value
  109. Dim CentrelinkIncome As Range
  110. Set CentrelinkIncome = ActiveDocument.Bookmarks("CentrelinkIncome").Range
  111. CentrelinkIncome Text = Me.TxtCentrelink.Value
  112. Dim AnlCentrelink As Range
  113. Set AnlCentrelink = ActiveDocument.Bookmarks("AnlCentrelink").Range
  114. AnlCentrelink Text = Me.TxtCentrelink.Value
  115. Dim SuperIncome As Range
  116. Set SuperIncome = ActiveDocument.Bookmarks("SuperIncome").Range
  117. SuperIncome Text = Me.TxtComSuper.Value
  118. Dim AnnuityIncome As Range
  119. Set AnnuityIncome = ActiveDocument.Bookmarks("AnnuityIncome").Range
  120. AnnuityIncome Text = Me.TxtOther.Value
  121. Dim rentalIncome As Range
  122. Set rentalIncome = ActiveDocument.Bookmarks("Rental Income").Range
  123. rentalIncome Text = Me.TxtRent.Value
  124. Dim TotalanlIncome As Range
  125. Set TotalanlIncome = ActiveDocument.Bookmarks("TotalanlIncome ").Range
  126. TotalanlIncome Text = Me.TxtIncomeTotal.Value
  127. Dim CurrentBudget As Range
  128. Set CurrentBudget = ActiveDocument.Bookmarks("CurrentBudget").Range
  129. CurrentBudget Text = Me.TxtBudget.Value
  130. Dim CurrentBudget2 As Range
  131. Set CurrentBudget2 = ActiveDocument.Bookmarks("CurrentBudget2").Range
  132. CurrentBudget2 Text = Me.TxtBudget.Value
  133. Dim Oneoffex As Range
  134. Set Oneoffex = ActiveDocument.Bookmarks("Oneoffex").Range
  135. Oneoffex Text = Me.TxtCapex.Value
  136. Dim Oneofex As Range
  137. Set Oneofex = ActiveDocument.Bookmarks("Oneofex").Range
  138. Oneofex Text = Me.TxtCapex.Value
  139. Dim Tagfees As Range
  140. Set Tagfees = ActiveDocument.Bookmarks("Tagfees").Range
  141. Tagfees Text = Me.TxtTagFees.Value
  142. Dim BudgetPeriod As Range
  143. Set BudgetPeriod = ActiveDocument.Bookmarks("BudgetPeriod").Range
  144. BudgetPeriod Text = Me.TxtBudgPeriod.Value
  145. 'Calculate todays date
  146. Dim Todaysdate As Range
  147. Set Todaysdate = ActiveDocument.Bookmarks("Todaysdate").Range
  148. Todaysdate Text = Today()
  149. 'calculate Cash Flow residual from Total Income-Total Expenses
  150. Dim BudgetResidual As Range
  151. Set BudgetResididual = ActiveDocument.Bookmarks("BudgetResidual").Range
  152. BudgetResidual Text = Me.TxtTotalIncome.Value - Me.TxtTotalIncome.Value
  153. Dim CashflowResidual As Range
  154. Set cashflowResididual = ActiveDocument.Bookmarks("CashflowResidual").Range
  155. CashflowResidual Text = BudgetResidual.Value
  156. Dim ABPInc As Range
  157. Set ABPInc = ActiveDocument.Bookmarks("ABPInc").Range
  158. ABPInc Text = Me.TxtABPen * Me.LstbxPenFact
  159. Dim ABPIncome As Range
  160. Set ABPIncome = ActiveDocument.Bookmarks("ABPIncome").Range
  161. ABPIncome Text = ActiveDocument.Bookmarks("ABPInc").Value
  162. 'Calculate Living Expenses from others
  163. Dim LivingExps As Range
  164. Set LivingExps = ActiveDocument.Bookmarks("LivingExp").Range
  165. LivingExps Text = Me.TxtBudget - (Me.TxtTagFees + Me.TxtCapex)
  166. 'Calculate Operating Expenses from LivingExp
  167. Dim OpEx As Range
  168. Set OpEx = ActiveDocument.Bookmarks("OpExp").Range
  169. OpEx Text = ActiveDocument.Range("LivingExps") + Me.TxtTagFees
  170. Dim NetOpRt As Range
  171. Set NetOpRt = ActiveDocument.Bookmarks("NetOpRt").Range
  172. NetOpRt Text = (Me.TxtCapex - Me.TxtTotlIncome) / (Me.TxtInvestments - Me.TxtCapex)
  173. Dim NetEx As Range
  174. Set NetEx = ActiveDocument.Bookmarks("NetEx").Range
  175. NetEx Text = Me.TxtTotalExpenses - Me.TxtTotlIncome / Me.TxtInvestments
  176. Dim GrossEx As Range
  177. Set GrossEx = ActiveDocument.Bookmarks("GrossEx").Range
  178. GrossEx = Me.TxtBudget / Me.TxtInvestments
  179.  
  180. End Sub
  181. Private Sub CmdCreateLocalCopy_Click() '(ByVal Item As Object, Cancel As Boolean)
  182. Call SaveACopy(Endorsebud)
  183. Const olMsg As Long = 3
  184. Dim m As MailItem
  185. Dim savePath As String
  186. If TypeName(Item) <> "MailItem" Then Exit Sub
  187. Set m = Item
  188. savePath = "c:usersyour_user_namedesktop" 'Change this to real path
  189. savePath = savePath & m.Subject & Format(Now(), "yyyy-mm-dd-hhNNss")
  190. savePath = savePath & ".msg"
  191. m.SaveAs savePath, olMsg
  192. End Sub
  193.  
  194. Private Sub TxtTotalExpenses_Change()
  195.  
  196. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement