472,958 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Word Templates using Visual Basic Editor

I am creating a template in Word 2007 using Visual Basic Editor. I am pulling information from an Access database. I know this is probably a stupid question, but for the life of me I can't figure out how I get my data to start on a new page and keep the formatting from the first page once a new record is encountered. I have attached a copy of my code. Any help will be greatly appreciated!!!

Expand|Select|Wrap|Line Numbers
  1. Public blnCancelled As Boolean 
  3. Private Sub btnCancel_Click() 
  4. DCAMacro.blnCancelled = True 
  5. Unload Me 
  6. End Sub 
  8. Private Sub btnGetData_Click() 
  9. Dim conn As New ADODB.Connection 
  10. Dim rs As New ADODB.Recordset 
  11. Dim lngConnectionState As Long 
  12. Dim strSQL As String 
  13. Dim Appellant As String 
  14. Dim Appellee As String 
  15. Dim DateMandateReleased As Date 
  16. Dim MandateType As String 
  18. '*****Set up the connection to the database***** 
  19. conn.ConnectionString = "Provider=MSDAORA; Data Source=TSD1; " 
  20. 'removed login information 
  22. '*****Open the connecton to the database***** 
  23. conn.Open 
  24. Set rs = New ADODB.Recordset 
  26. '*****Check the state of the database***** 
  27. lngConnectionState = conn.State 
  28. 'If lngConnectionState = adStateOpen Then 
  30. '*****Set the datasource***** 
  31. strSQL = "Select Mandate_Type, Parm1, Agency_Description, CaseNo, Appellant, Appellee, Lt_Cases, Opinion_Date, Chief_Judge, Mandate_Date " & _ 
  32.             "From CMS.V_Macro4mandate " & _ 
  33.             "Where Date_Mandate_Released = '25-April-2006' " 
  35. '*****Open the recordset***** 
  36. rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic 
  38. '*****Get the data if not end of the record set***** 
  39. rs.MoveFirst 
  40. If Not rs.EOF Then 
  41.     Do Until rs.EOF 
  42. DCAMacro.txtAppellant = rs.Fields("Appellant").Value & " " 
  43. DCAMacro.txtAppellee = rs.Fields("Appellee").Value & " " 
  44. DCAMacro.txtCaseNumber = rs.Fields("CaseNo").Value & " " 
  45. DCAMacro.txtLowerTrib = rs.Fields("LT_Cases").Value & " " 
  46. DCAMacro.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " 
  49. '*****Determine the type of mandate***** 
  50. 'If rs.Fields("Mandate_Type").Value = "DK09" Then 
  51. 'DCAMacro.txtMandate_Type = "Mandate" 
  52. 'End If 
  53. 'If rs.Fields("Mandate_Type").Value = "MA1" Then 
  54. 'DCAMacro.txtMandate_Type = "Agency Mandate" 
  55. 'End If 
  56. 'If rs.Fields("Mandate_Type").Value = "MA2" Then 
  57. 'DCAMacro.txtMandate_Type = "Circuit Court Mandate" 
  58. 'End If 
  59. 'If rs.Fields("Mandate_Type").Value = "MA3" Then 
  60. 'DCAMacro.txtMandate_Type = "Worker's Compensation Mandate" 
  61. 'End If 
  63. 'If rs.Fields("CaseNo").Value = "1D" Then 
  64. 'DCAMacro.txtDistrict = "first district" 
  65. 'End If 
  68. DCAMacro.Hide 'hide the form so the document can come up 
  69. Set DCAMarco = Nothing 
  71. '*****Add the generic text and properties that apply to all***** 
  73. '*****formatting for heading***** 
  74. Selection.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle 
  75. Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter 
  76. Selection.Font.Size = 38 
  77. Selection.Font.Name = "Times New Roman" 
  78. Selection.Font.Bold = wdToggle 
  79. Selection.TypeText Text:="M A N D A T E" 
  80. Selection.Font.Size = 12 
  81. Selection.TypeParagraph 
  82. Selection.TypeText Text:="From" 
  83. Selection.TypeParagraph 
  84. Selection.Font.Size = 14 
  85. Selection.Font.AllCaps = True 
  86. Selection.TypeText Text:="district court of appeal of florida" 
  87. Selection.TypeParagraph 
  88. Selection.TypeText Text:="first district" 
  89. 'Selection.TypeText Text:=txtDistrict.Value 
  90. Selection.Font.AllCaps = False 
  91. Selection.TypeParagraph 
  92. Selection.TypeParagraph 
  93. Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft 
  94. Selection.Font.Size = 11 
  95. Selection.TypeText Text:="To ~(name), ~(title), ~(agency)" 
  96. Selection.TypeParagraph 
  97. Selection.TypeParagraph 
  98. Selection.TypeText Text:="WHEREAS, in the certain cause filed in this Court styled:" 
  99. Selection.TypeParagraph 
  100. Selection.TypeParagraph 
  101. Selection.Font.AllCaps = True 
  102. Selection.TypeText Text:=txtAppellant.Value 
  103. Selection.Font.AllCaps = False 
  104. Selection.TypeText Text:=vbTab 
  105. Selection.TypeText Text:=vbTab 
  106. Selection.TypeText Text:=vbTab 
  107. Selection.TypeText Text:=vbTab 
  108. Selection.TypeText Text:=vbTab 
  109. Selection.TypeText Text:="Case No : " 
  110. Selection.TypeText Text:=txtCaseNumber.Value 
  111. Selection.TypeParagraph 
  112. Selection.TypeParagraph 
  113. Selection.TypeParagraph 
  114. Selection.TypeText Text:="v." 
  115. Selection.TypeText Text:=vbTab 
  116. Selection.TypeText Text:=vbTab 
  117. Selection.TypeText Text:=vbTab 
  118. Selection.TypeText Text:=vbTab 
  119. Selection.TypeText Text:=vbTab 
  120. Selection.TypeText Text:=vbTab 
  121. Selection.TypeText Text:=vbTab 
  122. Selection.TypeText Text:="Lower Tribunal Case No : " 
  123. Selection.TypeText Text:=txtLowerTrib.Value 
  124. Selection.TypeParagraph 
  125. Selection.TypeParagraph 
  126. Selection.TypeParagraph 
  127. Selection.Font.AllCaps = True 
  128. Selection.TypeText Text:=txtAppellee.Value 
  129. Selection.Font.AllCaps = False 
  130. Selection.TypeParagraph 
  131. Selection.TypeParagraph 
  132. Selection.TypeParagraph 
  133. Selection.TypeText Text:="The attached opinion was issued on " 
  134. Selection.TypeText Text:=rs.Fields("Opinion_Date").Value & " " 
  135. Selection.TypeParagraph 
  136. Selection.TypeText Text:="YOU ARE HEREBY COMMANDED that further proceedings, if required, be had in accordance" 
  137. Selection.TypeParagraph 
  138. Selection.TypeText Text:="with said opinion, the rules of Court, and the laws of the State of Florida." 
  139. Selection.TypeParagraph 
  140. Selection.SelectCurrentTabs 
  141. Selection.Paragraphs.TabIndent (1) 
  142. Selection.TypeText Text:="WITNESS the Honorable " 
  143. Selection.TypeText Text:=rs.Fields("Chief_Judge").Value & " " 
  144. Selection.TypeParagraph 
  145. Selection.SelectCurrentTabs 
  146. Selection.Paragraphs.TabIndent (1) 
  147. Selection.TypeText Text:="of the District Court of Appeal of Florida, First District" 
  148. 'Selection.TypeText Text:=txtDistrict.Value 
  149. Selection.TypeText Text:="," 
  150. Selection.TypeParagraph 
  151. Selection.SelectCurrentTabs 
  152. Selection.Paragraphs.TabIndent (1) 
  153. Selection.TypeText Text:="and the Seal of said Court done at Tallahassee, Florida," 
  154. 'Selection.TypeText Text:=txtCity.Text 
  155. Selection.TypeParagraph 
  156. Selection.SelectCurrentTabs 
  157. Selection.Paragraphs.TabIndent (1) 
  158. Selection.TypeText Text:="on this " 
  159. Selection.TypeText Text:=rs.Fields("Mandate_Date").Value & " " 
  160. Selection.ClearParagraphAllFormatting 
  162. rs.MoveNext 
  164.     Loop 
  165. End If 
  167. MsgBox "Done.", vbOKOnly 
  169. ' rs.Close 
  170. ' conn.Close 
  171. ' Set conn = Nothing 
  172. ' Set rs = Nothing 
  174. End Sub 
Jan 16 '07 #1
2 2570
hello dear
plz help me soon yaar

1.> How can i create a macro in msword using visul basic editor and how it saves after saving how this macro call in visual basic6

2.> give me full info for this code its very urgent for my educational project.

plz help me soon
Mar 15 '07 #2
hello dear
plz help me soon yaar

1.> How can i create a macro in msword using visul basic editor and how it saves after saving how this macro call in visual basic6

2.> give me full info for this code its very urgent for my educational project.

plz help me soon

replay me on
Mar 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
by: pontifikas | last post by:
I'm having hard time finding documentation for Word.Document or Word.Application classes and there is something I need to do. I want to know how to read from a word file and how to maintain...
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word"...
by: Keith Butler | last post by:
H Very new to CHM file. My question is can I create CHM file from a word document (or any other document)? Appreciate links to any good article on creation of CH Thank Keit
by: Dixie | last post by:
Is there a way to shell to Microsoft Word from Access and load a specific template - using VBA? dixie
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking...
by: =?Utf-8?B?QmVuamFtaW5vNQ==?= | last post by:
Apologies if this is the wrong forum. I normally post in the Word Programming group, but this seemed like more of a VB.Net question. I'm moving code from VBA over to Visual Studio Express 2005...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.