Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
|
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2011, 09:38 AM
Registered User
 
Join Date: Sep 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Access to Word With Group Headings in Table

I posted this to one other forum but I've received no comments at all so far.

I have the following code in an Access database

Code:
Set RST = DB.OpenRecordset(MySQL, dbOpenDynaset)
            If Not (RST.BOF) And Not (RST.EOF) Then
             RST.MoveLast
             MyCount = RST.RecordCount
             RST.MoveFirst
             MyTempCodegroup = RST!leftcodegroup
             
                            N = MyCount + 3
                            WordObj.ActiveDocument.Bookmarks("NeshapTable").Select
                            WordObj.ActiveDocument.Tables.Add Range:=WordObj.Selection.Range, numrows:=MyCount + 3, numcolumns:=2, defaulttablebehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
                            WordObj.ActiveDocument.Tables(7).Columns(1).SetWidth ColumnWidth:=100, RulerStyle:=wdAdjustNone
                            WordObj.ActiveDocument.Tables(7).Columns(2).SetWidth ColumnWidth:=430, RulerStyle:=wdAdjustNone

                                Do While Not RST.EOF

                                    WordObj.ActiveDocument.Tables(7).Cell(Row:=N, Column:=1).Range.InsertAfter Text:=RST!NeshapCodePart2
                                    WordObj.ActiveDocument.Tables(7).Cell(Row:=N, Column:=1).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
                                    WordObj.ActiveDocument.Tables(7).Cell(Row:=N, Column:=2).Range.InsertAfter Text:=RST!NOVNRELanguage
                                    'WordObj.ActiveDocument.Tables(4).Cell(Row:=N, Column:=2).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
                                    WordObj.ActiveDocument.Tables(7).Cell(Row:=N, Column:=2).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
   
                                N = N - 1
                                RST.MoveNext
                                Loop
                                
                                    WordObj.ActiveDocument.Tables(7).Cell(Row:=N, Column:=1).Range.InsertAfter Text:=RST!leftcodegroup
                                    WordObj.ActiveDocument.Tables(7).Cell(Row:=N, Column:=1).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
                                    N = N - 1

                             End If

=================================================

This is creating a Word table that looks like the following:



(k) Failure to conduct weekly perceptible leak inspections while machine is in operation [63.322(k)].
(i) Failure to drain all cartridge filters in their housing, or other sealed container, for a minimum of 24 hours, before removal from the dry cleaning facility [63.322(i)].

63.322
(a)(1)(ii) Failure to monitor on a weekly basis either the refrigeration system high pressure and low pressure readings during the drying phase to determine if they are in the range specified in the manufacturer's operating instructions, or the condenser exit temperatures to ensure the perc vapor air stream flowing through the refrigerated condenser before the end of the drying cycle does not exceed 45 degrees Fahrenheit (7.2 degrees Celsius) [63.323(a)(1)(i) or (ii)].
(a)(1)(i) Failure to monitor on a weekly basis either the refrigeration system high pressure and low pressure readings during the drying phase to determine if they are in the range specified in the manufacturer's operating instructions, or the condenser exit temperatures to ensure the perc vapor air stream flowing through the refrigerated condenser before the end of the drying cycle does not exceed 45 degrees Fahrenheit (7.2 degrees Celsius) [63.323(a)(1)(i) or (ii)].

63.323

================================================== ======

What I want is subgroup headings where 63.323 is at the start of the subgroup and 63.322 is at the start of its subgroup etc.

The name of the column the heading is in is called leftcodegroup.

The data is coming out the way that I want it but I can not get the codegroup heading in the right spot so that it's actually at teh beginning of it's specific group. I'm sure there's something I'm doing wrong with and probably with wdcollapse but I can't find it. Suggestions would be greatly appreciated
 
Old September 4th, 2011, 10:42 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Though the problem looks nice having a simulation is quite tough assuming the connection and data needed to do that.

One try you can do is to press F8 and catch the culprit. It looks like there is some discrepency in the format that gets applied

At times if there is no Carriage Return between the paragraphs, the format of the previous format gets applied. Not sure what would be the reason

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
group data in table based on a value praveenanekalmat XSLT 2 January 7th, 2009 03:09 AM
Group by Weeks in a query or table lryckman Access VBA 4 December 4th, 2006 08:55 AM
Word Editor in VB and integrating to Access table akash VB How-To 1 April 11th, 2005 08:19 AM
Table headings don't appear correctly Ben Horne Dreamweaver (all versions) 5 September 14th, 2004 08:45 AM
Exporting to Excel from Access - field headings no chimp Access VBA 1 July 9th, 2004 11:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.