Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Column Break Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pkruti@hotmail.com - 06 Apr 2005 17:32 GMT
I am trying to create a word document using VB6 and need to use columns
breaks but cant seem to find out why my code doesnt work the way it
should. It creates a column break but when i trying to go back to one
column to finish off the document it takes the second column and puts
it on the next page. Any ideas on what i may be doing wrong with the
code below?

With surveyApp.Selection

surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
End:=.Start).InsertBreak
Type:=wdSectionBreakContinuous
.Start = .Start + 1
With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
End:=surveyApp.ActiveDocument.­­­­Content.End).PageSetup.Text­C­o­l­umns

.SetCount numcolumns:=2
.EvenlySpaced = True
.LineBetween = False
.Width = InchesToPoints(2.75)
.Spacing = InchesToPoints(0.5)
End With

Dim rs3 As New ADODB.Recordset
Dim rs4 As New ADODB.Recordset
Dim cmd As New ADODB.Command
cmd.ActiveConnection = conn

rs3.Open "SELECT * FROM groupname", conn, adOpenDynamic,
adLockOptimistic

   If rs3.EOF Then
       .TypeText Text:="None indicated"
       .TypeParagraph
       .TypeParagraph
       rs3.Close
   Else

   'Setup for mutliple columns
   Dim currentline As Integer
   Dim group(500) As Integer 'this is the line that the group starts
on
   Dim currentgroup As Integer
   Dim lines(500) As Integer 'this is the current group for a given
line

   currentline = 0
   currentgroup = 0

   While Not rs3.EOF
   currentgroup = currentgroup + 1
   group(currentgroup) = currentline
   lines(currentline) = currentgroup
   .TypeText Text:=rs3("groupname")
   .TypeText vbTab
   .TypeText Text:=rs3("problem")
   .TypeParagraph
   currentline = currentline + 1

   rs4.Open "SELECT * From problemoccurred WHERE groupname = '" &
rs3!GroupName & "' order by problemoccurred desc", conn, adOpenDynamic,

adLockOptimistic

   While Not rs4.EOF
   .TypeText Text:=rs4("problemdesc")
   lines(currentline) = currentgroup
   .TypeText vbTab
   .TypeText Text:=rs4("problemoccurred")
   .TypeParagraph
   currentline = currentline + 1
'    .MoveRight unit:=wdCell
'    .MoveRight unit:=wdCell
   rs4.MoveNext
Wend
   rs4.Close
   rs3.MoveNext
Wend
   rs3.Close

If currentgroup > 1 Then
   Dim gobackto As Integer
   If lines(currentline / 2) = 1 Then
   gobackto = group(2)
Else

   gobackto = group(lines(currentline / 2))

End If

   .MoveUp unit:=wdLine, Count:=(currentline - gobackto)
   .InsertBreak wdColumnBreak

End If

.EndKey wdStory
With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
End:=.End).PageSetup.TextColum­­­­ns
.SetCount numcolumns:=1
.EvenlySpaced = True
.LineBetween = False
End With

End If
End With
Chuck - 06 Apr 2005 18:23 GMT
At the end of the code you're posting you are selecting the entire document
before you set the column count to 1 - so the colum break becomes in effect a
page break (because there's only one column).

You need to set your range to where you want to go back to one column -- if
that's the end of the document, it's simple:

With ActiveDocument.Range
 .Start = ActiveDocument.Range.End
 .Start = ActiveDocument.Range.End
 .InsertBreak Type:=wdSectionBreakContinuous
 With .PageSetup.TextColumns
   .SetCount 1
   .EvenlySpaced = True
   .LineBetween = False
 End With
End With

With surveyApp.ActiveDocument.Range­­­­(Start:=.Start, End:=.End)

> I am trying to create a word document using VB6 and need to use columns
> breaks but cant seem to find out why my code doesnt work the way it
[quoted text clipped - 101 lines]
> End If
> End With
Chuck - 06 Apr 2005 18:23 GMT
OOPS

Code should have read:

With ActiveDocument.Range
 .Start = ActiveDocument.Range.End
 .End = ActiveDocument.Range.End
 .InsertBreak _
 Type:=wdSectionBreakContinuous
 With .PageSetup.TextColumns
 .SetCount numcolumns:=1
 .EvenlySpaced = True
 .LineBetween = False
 End With
End With

> I am trying to create a word document using VB6 and need to use columns
> breaks but cant seem to find out why my code doesnt work the way it
[quoted text clipped - 101 lines]
> End If
> End With
pkruti@hotmail.com - 06 Apr 2005 19:20 GMT
Thank you very much that helped alot.

kruti

> OOPS
>
[quoted text clipped - 26 lines]
> > ..Start = .Start + 1
> > With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,

End:=surveyApp.ActiveDocument.­­­­Content.End).PageSetup.Text­C­o­l­umns

> > ..SetCount numcolumns:=2
> > ..EvenlySpaced = True
[quoted text clipped - 85 lines]
> > End If
> > End With
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.