473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Using the NextParagraphStyle property

Good afternoon all,

I am trying to build a document within VB. I am currently outputting three recordsets from a query.

Each record set has a different paragraph style (Heading 1, Heading 8, and normal)

I have been trying to use the nextparagraphstyle property, but my document is still doing what it wants to do.

Below is a snippet of the code, and any assistance you have to offer is greatly appreciated:

Expand|Select|Wrap|Line Numbers
  1. Public Function gettbldata()
  2.  
  3. Dim rst3 As New ADODB.Recordset
  4. Dim strSQL As String
  5. Dim objdoc As Word.Document
  6.  
  7. If Not (objdoc Is Nothing) Then
  8.     MsgBox "Application already running"
  9.     Exit Function
  10. End If
  11.  
  12. objApp.Visible = True
  13.  
  14. 'Add a document to the application
  15.  
  16. Set objdoc = objApp.Documents.Add()
  17.  
  18.  
  19. strSQL = "SELECT SSR2_Table.MainSectionLabel, SSR2_Table.MainLabel, SSR2_Table.SummaryTextBox" & _
  20. " FROM (SSR_DataReportName INNER JOIN SSR_DataReportLabels ON SSR_DataReportName.[DataReport ID]" & _
  21. " = SSR_DataReportLabels.DataReportID) INNER JOIN SSR2_Table ON SSR_DataReportLabels.DataReportID" & _
  22. " = SSR2_Table.DataReportID WHERE (((SSR2_Table.DataReportID)=1));"
  23.  
  24. rst3.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockPessimistic
  25.  
  26.  
  27.     'objdoc.Content.ParagraphFormat.style = wdStyleHeading1
  28.     objdoc.Sections(1).Range.style = wdStyleHeading1
  29.     gettbldata = rst3.Fields(0)
  30.     objdoc.Content = gettbldata & vbCrLf
  31.  
  32.     gettbldata = rst3.Fields(1)
  33.     ActiveDocument.Range.InsertAfter Text:=gettbldata & vbCrLf & vbCrLf
  34.     objdoc.Sentences(2).style = wdStyleHeading8
  35.  
  36.     gettbldata = rst3.Fields(2)
  37.     objdoc.Range.InsertAfter Text:=gettbldata
  38.  
  39. Set rst3 = Nothing
  40. End Function
Feb 9 '07 #1
1 2147
ADezii
8,834 Expert 8TB
Good afternoon all,

I am trying to build a document within VB. I am currently outputting three recordsets from a query.

Each record set has a different paragraph style (Heading 1, Heading 8, and normal)

I have been trying to use the nextparagraphstyle property, but my document is still doing what it wants to do.

Below is a snippet of the code, and any assistance you have to offer is greatly appreciated:

Public Function gettbldata()

Dim rst3 As New ADODB.Recordset
Dim strSQL As String
Dim objdoc As Word.Document

If Not (objdoc Is Nothing) Then
MsgBox "Application already running"
Exit Function
End If

objApp.Visible = True

'Add a document to the application

Set objdoc = objApp.Documents.Add()


strSQL = "SELECT SSR2_Table.MainSectionLabel, SSR2_Table.MainLabel, SSR2_Table.SummaryTextBox" & _
" FROM (SSR_DataReportName INNER JOIN SSR_DataReportLabels ON SSR_DataReportName.[DataReport ID]" & _
" = SSR_DataReportLabels.DataReportID) INNER JOIN SSR2_Table ON SSR_DataReportLabels.DataReportID" & _
" = SSR2_Table.DataReportID WHERE (((SSR2_Table.DataReportID)=1));"

rst3.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockPessimistic


'objdoc.Content.ParagraphFormat.style = wdStyleHeading1
objdoc.Sections(1).Range.style = wdStyleHeading1
gettbldata = rst3.Fields(0)
objdoc.Content = gettbldata & vbCrLf

gettbldata = rst3.Fields(1)
ActiveDocument.Range.InsertAfter Text:=gettbldata & vbCrLf & vbCrLf
objdoc.Sentences(2).style = wdStyleHeading8

gettbldata = rst3.Fields(2)
objdoc.Range.InsertAfter Text:=gettbldata

Set rst3 = Nothing
End Function
Here is the correct Syntax for the NextParagraphStyle Property:

Expand|Select|Wrap|Line Numbers
  1. ActiveDocument.Styles(wdStyleHeading1).NextParagraphStyle = ActiveDocument.Styles(wdStyleHeading2)
  2.  
  3.  
  4. This example creates a new document and adds a paragraph style named "MyStyle." 
  5. The new style is based on the Normal style, is followed by the 
  6. Heading 3 style, has a left indent of 1 inch (72 points), and is bold.
  7.  
  8. Set myDoc = Documents.Add
  9. Set myStyle = myDoc.Styles.Add(Name:= "MyStyle")
  10.     With myStyle
  11.         .BaseStyle = wdStyleNormal
  12.         .NextParagraphStyle = wdStyleHeading3
  13.         .ParagraphFormat.LeftIndent = 72
  14.         .Font.Bold = True
  15.     End With
Feb 10 '07 #2

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
22
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
0
by: Horia Tudosie | last post by:
Using Visual Studio 2003 This is to report a series of bugs regarding the FlagsAttribute and (independently) the usage of interfaces in Web applications. Let’s declare xColors type like: ...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
11
by: Brent Ritchie | last post by:
Hello all, I have been using C# in my programming class and I have grown quite fond of C# properties. Having a method act like a variable that I can control access to is really something. As...
3
by: Mark R. Dawson | last post by:
Hi all, I am trying to get custom attributes from a property. I can do this if I pass in the name of the property i.e. "Name" to the reflection methods, but if I pass in set_Name which is what...
2
by: Tugrul HELVACI | last post by:
I'm using Delphi 2006 and I have a class defination like this: TPerson = class fPersonName : String; fPersonSurName : String; fPersonAge : Integer; published property PersonName : String...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.