473,585 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Word Templates using Visual Basic Editor

1 New Member
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 
  2.  
  3. Private Sub btnCancel_Click() 
  4. DCAMacro.blnCancelled = True 
  5. Unload Me 
  6. End Sub 
  7.  
  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 
  17.  
  18. '*****Set up the connection to the database***** 
  19. conn.ConnectionString = "Provider=MSDAORA; Data Source=TSD1; " 
  20. 'removed login information 
  21.  
  22. '*****Open the connecton to the database***** 
  23. conn.Open 
  24. Set rs = New ADODB.Recordset 
  25.  
  26. '*****Check the state of the database***** 
  27. lngConnectionState = conn.State 
  28. 'If lngConnectionState = adStateOpen Then 
  29.  
  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' " 
  34.  
  35. '*****Open the recordset***** 
  36. rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic 
  37.  
  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 & " " 
  47.  
  48.  
  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 
  62.  
  63. 'If rs.Fields("CaseNo").Value = "1D" Then 
  64. 'DCAMacro.txtDistrict = "first district" 
  65. 'End If 
  66.  
  67.  
  68. DCAMacro.Hide 'hide the form so the document can come up 
  69. Set DCAMarco = Nothing 
  70.  
  71. '*****Add the generic text and properties that apply to all***** 
  72.  
  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 
  161.  
  162. rs.MoveNext 
  163.  
  164.     Loop 
  165. End If 
  166.  
  167. MsgBox "Done.", vbOKOnly 
  168.  
  169. ' rs.Close 
  170. ' conn.Close 
  171. ' Set conn = Nothing 
  172. ' Set rs = Nothing 
  173.  
  174. End Sub 
Jan 16 '07 #1
2 2616
rinku123
10 New Member
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
rinku123
10 New Member
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
amitkumar19@gma il.com
Mar 15 '07 #3

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

Similar topics

5
7408
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 collection that I need. To begin, I am using xsltproc that conmes with Cygwin as my processor. I have no particular affinity to this processor except...
121
9988
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 support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather...
8
3503
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 the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word...
3
2010
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 formatting(Bolds, itallics etc). Also can I write , say bold, characters in a word file?How? Thanks in advance :)
12
4159
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" Response.AddHeader("content-disposition", "inline; filename=BP_CaseStatus.doc") Now all I should have to do is create the page just like I would if I were...
6
30900
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
12
10647
by: Dixie | last post by:
Is there a way to shell to Microsoft Word from Access and load a specific template - using VBA? dixie
7
7232
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 for any comments about the use of the docmd.transfertext method instead of the code Albert used for creating the text file. Also, perhaps some...
4
2734
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 (Visual Basic) while still learning about VB.Net. (Not a good combination, I know.) One problem I'm seeing is that certain lines of code that work...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.