Reply
 
Thread Tools Display Modes
  #1   Report Post  
moishy moishy is offline
Junior Member
 
Posts: 4
Default Page Layout in multi-column documents

I've posted a question on http://social.msdn.microsoft.com/For...1-1d39f5219b33 but it has seemingly come to a dead end (i.e. no response).

Here's the issue I'm dealing with, page layout in multi-column documents, since Word is not a desktop publishing solution, it doesn't have a built-in option to align all columns equally at the bottom, and therefore I have to do it manually. I'm using a function to find the difference in points between two columns, the trouble is it doesn't always work, sometimes it will return a value of several hundred points when there hardly is a difference at all.

I'm posting the function here; I would appreciate any help I can get in solving the mystery, and or improve the function.

Please note:
a. Although I will appreciate any help including alternative suggestions, I would prefer if I can get some help with the function I'm currently using.
b. The function must work on a right-to-left format document.
c. Speed is a very important factor, as I plan to use the function to display the difference in a text box on a user form that will get updated every time a change is made to one of the columns.

Code:
Function ColumnDiff()

  Dim i As Integer, iCounter As Integer, iPos As Long, iPosCol As Long
  Dim iCol() As Currency, nCol As Integer
  Dim myRange As Range, iViewType As Integer, bEnd As Boolean
  
  Const MaxDiff = 0 ' difference (in points) for the function to ignore
  
  If Selection.StoryType  1 Then MsgBox "Cursor not in main text!": Exit Function
  Set myRange = Selection.Range
  Application.ScreenUpdating = False
  iViewType = ActiveWindow.View.Type: ActiveWindow.View.Type = wdPrintView
  iPos = -1
  With Selection
      .Collapse wdCollapseEnd
      iCounter = iCounter + 1: StatusBar = iCounter
      While iPos  .Start
X2:       iPos = .Start
          If Dialogs(wdDialogFormatColumns).Columns = 1 Then GoTo X0
          ReDim iCol(Dialogs(wdDialogFormatColumns).Columns + 1)
          iPosCol = iPos: iPos = iPos - 1: nCol = 0
          While iPos  .Start
              iPos = .Start
              If Dialogs(wdDialogFormatColumns).Columns = 1 _
                  Or Dialogs(wdDialogFormatColumns).ColumnNo  nCol _
                  Then GoTo X1
              nCol = Dialogs(wdDialogFormatColumns).ColumnNo
              iCol(nCol) = .Information(wdVerticalPositionRelativeToPage)
              .GoToNext wdGoToLine
              iCounter = iCounter + 1: StatusBar = iCounter
          Wend
          bEnd = True: iPos = ActiveDocument.StoryRanges(1).End
X1:       For i = 1 To nCol ' iCol(0) = high peak
              If iCol(0)  iCol(i) Then iCol(0) = iCol(i)
          Next i
          iCol(nCol + 1) = iCol(0) ' iCol(nCol + 1) = low peak
          For i = 1 To nCol
              If iCol(nCol + 1)  iCol(i) Then iCol(nCol + 1) = iCol(i)
          Next i
          If iCol(0) - iCol(nCol + 1)  MaxDiff Then
              .SetRange iPosCol, iPos
              Application.ScreenUpdating = True
              ColumnDiff = CCur(iCol(0) - iCol(i)) ' & "pt"
              Exit Function
          End If
          If bEnd Then GoTo X3 Else GoTo X2
X0:       .GoToNext wdGoToLine
          iCounter = iCounter + 1: StatusBar = iCounter
      Wend
  End With
X3:   myRange.Select
      Application.ScreenUpdating = True: ActiveWindow.View.Type = iViewType
      MsgBox "Done!"
  
  End Function
Limitations of the function (not problems!):
1. The function will only find the difference in the main text and not in footnotes etc.
2. The function starts searching from the cursor location (or the end of the selected text) till the end of the document.


Related Question:
http://social.msdn.microsoft.com/For...7-2dec56a1313c


At the above url Macropad MVP has suggested several alternatives, as mentioned there either the macro was too slow or I was not able to get it to work in right-to-left format.
  #2   Report Post  
Posted to microsoft.public.word.pagelayout
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Page Layout in multi-column documents

Columns will be balanced if you insert a Continuous section break at the end
of the multi-column section.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"moishy" wrote in message
...

I've posted a question on http://tinyurl.com/6mflczk but it has
seemingly come to a dead end (i.e. no response).

Here's the issue I'm dealing with, page layout in multi-column
documents, since Word is not a desktop publishing solution, it doesn't
have a built-in option to align all columns equally at the bottom, and
therefore I have to do it manually. I'm using a function to find the
difference in points between two columns, the trouble is it doesn't
always work, sometimes it will return a value of several hundred points
when there hardly is a difference at all.

I'm posting the function here; I would appreciate any help I can get in
solving the mystery, and or improve the function.

Please note:
a. Although I will appreciate any help including alternative
suggestions, I would prefer if I can get some help with the function I'm
currently using.
b. The function must work on a right-to-left format
document.
c. Speed is a very important factor, as I plan to use
the function to display the difference in a text box on a user form that
will get updated every time a change is made to one of the columns.


Code:
--------------------

Function ColumnDiff()

Dim i As Integer, iCounter As Integer, iPos As Long, iPosCol As Long
Dim iCol() As Currency, nCol As Integer
Dim myRange As Range, iViewType As Integer, bEnd As Boolean

Const MaxDiff = 0 ' difference (in points) for the function to ignore

If Selection.StoryType 1 Then MsgBox "Cursor not in main text!": Exit
Function
Set myRange = Selection.Range
Application.ScreenUpdating = False
iViewType = ActiveWindow.View.Type: ActiveWindow.View.Type = wdPrintView
iPos = -1
With Selection
.Collapse wdCollapseEnd
iCounter = iCounter + 1: StatusBar = iCounter
While iPos .Start
X2: iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 Then GoTo X0
ReDim iCol(Dialogs(wdDialogFormatColumns).Columns + 1)
iPosCol = iPos: iPos = iPos - 1: nCol = 0
While iPos .Start
iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 _
Or Dialogs(wdDialogFormatColumns).ColumnNo nCol _
Then GoTo X1
nCol = Dialogs(wdDialogFormatColumns).ColumnNo
iCol(nCol) = .Information(wdVerticalPositionRelativeToPage)
.GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
bEnd = True: iPos = ActiveDocument.StoryRanges(1).End
X1: For i = 1 To nCol ' iCol(0) = high peak
If iCol(0) iCol(i) Then iCol(0) = iCol(i)
Next i
iCol(nCol + 1) = iCol(0) ' iCol(nCol + 1) = low peak
For i = 1 To nCol
If iCol(nCol + 1) iCol(i) Then iCol(nCol + 1) = iCol(i)
Next i
If iCol(0) - iCol(nCol + 1) MaxDiff Then
.SetRange iPosCol, iPos
Application.ScreenUpdating = True
ColumnDiff = CCur(iCol(0) - iCol(i)) ' & "pt"
Exit Function
End If
If bEnd Then GoTo X3 Else GoTo X2
X0: .GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
End With
X3: myRange.Select
Application.ScreenUpdating = True: ActiveWindow.View.Type = iViewType
MsgBox "Done!"

End Function

--------------------


LIMITATIONS OF THE FUNCTION (NOT PROBLEMS!):
1. The function will only find the difference in the main text and not
in footnotes etc.
2. The function starts searching from the cursor location (or the end of
the selected text) till the end of the document.


RELATED QUESTION:
http://tinyurl.com/7ju2puy


At the above url Macropad MVP has suggested several alternatives, as
mentioned there either the macro was too slow or I was not able to get
it to work in right-to-left format.




--
moishy


  #3   Report Post  
moishy moishy is offline
Junior Member
 
Posts: 4
Default

Suzanne,

I do that, but it will not balance the columns accurately if one column has more lines than the other, or if one column has more paragraphs than the other and spacing is used before or after the paragraphs.

I use macros kindly provided at http://tinyurl.com/7ju2puy

Quote:
Originally Posted by Suzanne S. Barnhill View Post
Columns will be balanced if you insert a Continuous section break at the end
of the multi-column section.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org


"moishy" wrote in message

I've posted a question on http://tinyurl.com/6mflczk but it has
seemingly come to a dead end (i.e. no response).

Here's the issue I'm dealing with, page layout in multi-column
documents, since Word is not a desktop publishing solution, it doesn't
have a built-in option to align all columns equally at the bottom, and
therefore I have to do it manually. I'm using a function to find the
difference in points between two columns, the trouble is it doesn't
always work, sometimes it will return a value of several hundred points
when there hardly is a difference at all.

I'm posting the function here; I would appreciate any help I can get in
solving the mystery, and or improve the function.

Please note:
a. Although I will appreciate any help including alternative
suggestions, I would prefer if I can get some help with the function I'm
currently using.
b. The function must work on a right-to-left format
document.
c. Speed is a very important factor, as I plan to use
the function to display the difference in a text box on a user form that
will get updated every time a change is made to one of the columns.


Code:
--------------------

Function ColumnDiff()

Dim i As Integer, iCounter As Integer, iPos As Long, iPosCol As Long
Dim iCol() As Currency, nCol As Integer
Dim myRange As Range, iViewType As Integer, bEnd As Boolean

Const MaxDiff = 0 ' difference (in points) for the function to ignore

If Selection.StoryType 1 Then MsgBox "Cursor not in main text!": Exit
Function
Set myRange = Selection.Range
Application.ScreenUpdating = False
iViewType = ActiveWindow.View.Type: ActiveWindow.View.Type = wdPrintView
iPos = -1
With Selection
.Collapse wdCollapseEnd
iCounter = iCounter + 1: StatusBar = iCounter
While iPos .Start
X2: iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 Then GoTo X0
ReDim iCol(Dialogs(wdDialogFormatColumns).Columns + 1)
iPosCol = iPos: iPos = iPos - 1: nCol = 0
While iPos .Start
iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 _
Or Dialogs(wdDialogFormatColumns).ColumnNo nCol _
Then GoTo X1
nCol = Dialogs(wdDialogFormatColumns).ColumnNo
iCol(nCol) = .Information(wdVerticalPositionRelativeToPage)
.GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
bEnd = True: iPos = ActiveDocument.StoryRanges(1).End
X1: For i = 1 To nCol ' iCol(0) = high peak
If iCol(0) iCol(i) Then iCol(0) = iCol(i)
Next i
iCol(nCol + 1) = iCol(0) ' iCol(nCol + 1) = low peak
For i = 1 To nCol
If iCol(nCol + 1) iCol(i) Then iCol(nCol + 1) = iCol(i)
Next i
If iCol(0) - iCol(nCol + 1) MaxDiff Then
.SetRange iPosCol, iPos
Application.ScreenUpdating = True
ColumnDiff = CCur(iCol(0) - iCol(i)) ' & "pt"
Exit Function
End If
If bEnd Then GoTo X3 Else GoTo X2
X0: .GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
End With
X3: myRange.Select
Application.ScreenUpdating = True: ActiveWindow.View.Type = iViewType
MsgBox "Done!"

End Function

--------------------


LIMITATIONS OF THE FUNCTION (NOT PROBLEMS!):
1. The function will only find the difference in the main text and not
in footnotes etc.
2. The function starts searching from the cursor location (or the end of
the selected text) till the end of the document.


RELATED QUESTION:
http://tinyurl.com/7ju2puy


At the above url Macropad MVP has suggested several alternatives, as
mentioned there either the macro was too slow or I was not able to get
it to work in right-to-left format.

--
moishy
[/i][/color]
  #4   Report Post  
Posted to microsoft.public.word.pagelayout
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default Page Layout in multi-column documents

Actually, Word does a fairly good job balancing columns when the column ends
in a continuous section break. But note that it is not going to work if the
columns contain a manual break somewhere.

However, if you are saying that you want the lines to match exactly (across
columns), you will have to specify a fixed value for line spacing, and a
value for spacing before which is an integer multiple of the line spacing.

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"moishy" wrote in message ...


Suzanne,

I do that, but it will not balance the columns accurately if one column
has more lines than the other, or if one column has more paragraphs than
the other and spacing is used before or after the paragraphs.

I use macros kindly provided at http://tinyurl.com/7ju2puy

Suzanne S. Barnhill;492068 Wrote:
Columns will be balanced if you insert a Continuous section break at the
end
of the multi-column section.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org


"moishy" wrote in message

I've posted a question on http://tinyurl.com/6mflczk but it has
seemingly come to a dead end (i.e. no response).

Here's the issue I'm dealing with, page layout in multi-column
documents, since Word is not a desktop publishing solution, it doesn't
have a built-in option to align all columns equally at the bottom, and
therefore I have to do it manually. I'm using a function to find the
difference in points between two columns, the trouble is it doesn't
always work, sometimes it will return a value of several hundred points
when there hardly is a difference at all.

I'm posting the function here; I would appreciate any help I can get in
solving the mystery, and or improve the function.

Please note:
a. Although I will appreciate any help including alternative
suggestions, I would prefer if I can get some help with the function
I'm
currently using.
b. The function must work on a right-to-left format
document.
c. Speed is a very important factor, as I plan to use
the function to display the difference in a text box on a user form
that
will get updated every time a change is made to one of the columns.


Code:
--------------------

Function ColumnDiff()

Dim i As Integer, iCounter As Integer, iPos As Long, iPosCol As Long
Dim iCol() As Currency, nCol As Integer
Dim myRange As Range, iViewType As Integer, bEnd As Boolean

Const MaxDiff = 0 ' difference (in points) for the function to ignore

If Selection.StoryType 1 Then MsgBox "Cursor not in main text!": Exit

Function
Set myRange = Selection.Range
Application.ScreenUpdating = False
iViewType = ActiveWindow.View.Type: ActiveWindow.View.Type =
wdPrintView
iPos = -1
With Selection
.Collapse wdCollapseEnd
iCounter = iCounter + 1: StatusBar = iCounter
While iPos .Start
X2: iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 Then GoTo X0
ReDim iCol(Dialogs(wdDialogFormatColumns).Columns + 1)
iPosCol = iPos: iPos = iPos - 1: nCol = 0
While iPos .Start
iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 _
Or Dialogs(wdDialogFormatColumns).ColumnNo nCol _
Then GoTo X1
nCol = Dialogs(wdDialogFormatColumns).ColumnNo
iCol(nCol) = .Information(wdVerticalPositionRelativeToPage)
.GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
bEnd = True: iPos = ActiveDocument.StoryRanges(1).End
X1: For i = 1 To nCol ' iCol(0) = high peak
If iCol(0) iCol(i) Then iCol(0) = iCol(i)
Next i
iCol(nCol + 1) = iCol(0) ' iCol(nCol + 1) = low peak
For i = 1 To nCol
If iCol(nCol + 1) iCol(i) Then iCol(nCol + 1) = iCol(i)
Next i
If iCol(0) - iCol(nCol + 1) MaxDiff Then
.SetRange iPosCol, iPos
Application.ScreenUpdating = True
ColumnDiff = CCur(iCol(0) - iCol(i)) ' & "pt"
Exit Function
End If
If bEnd Then GoTo X3 Else GoTo X2
X0: .GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
End With
X3: myRange.Select
Application.ScreenUpdating = True: ActiveWindow.View.Type = iViewType
MsgBox "Done!"

End Function

--------------------


LIMITATIONS OF THE FUNCTION (NOT PROBLEMS!):
1. The function will only find the difference in the main text and not
in footnotes etc.
2. The function starts searching from the cursor location (or the end
of
the selected text) till the end of the document.


RELATED QUESTION:
http://tinyurl.com/7ju2puy


At the above url Macropad MVP has suggested several alternatives, as
mentioned there either the macro was too slow or I was not able to get
it to work in right-to-left format.

--
moishy
[/i][/color]




--
moishy


  #5   Report Post  
moishy moishy is offline
Junior Member
 
Posts: 4
Default

Stefan,

Ideally your suggestion of using fixed line spacing is the right way to go in setting up a new document, the trouble is I'm dealing with many documents from many sources which cannot be counted upon to set up the document properly.
Also, your suggestion won't help in case of a one line longer paragraph on one side.
Quote:
Originally Posted by Stefan Blom[_3_] View Post
Actually, Word does a fairly good job balancing columns when the column ends
in a continuous section break. But note that it is not going to work if the
columns contain a manual break somewhere.

However, if you are saying that you want the lines to match exactly (across
columns), you will have to specify a fixed value for line spacing, and a
value for spacing before which is an integer multiple of the line spacing.

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"moishy" wrote in message ...


Suzanne,

I do that, but it will not balance the columns accurately if one column
has more lines than the other, or if one column has more paragraphs than
the other and spacing is used before or after the paragraphs.

I use macros kindly provided at http://tinyurl.com/7ju2puy

Suzanne S. Barnhill;492068 Wrote:
Columns will be balanced if you insert a Continuous section break at the
end
of the multi-column section.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org


"moishy" wrote in message

I've posted a question on http://tinyurl.com/6mflczk but it has
seemingly come to a dead end (i.e. no response).

Here's the issue I'm dealing with, page layout in multi-column
documents, since Word is not a desktop publishing solution, it doesn't
have a built-in option to align all columns equally at the bottom, and
therefore I have to do it manually. I'm using a function to find the
difference in points between two columns, the trouble is it doesn't
always work, sometimes it will return a value of several hundred points
when there hardly is a difference at all.

I'm posting the function here; I would appreciate any help I can get in
solving the mystery, and or improve the function.

Please note:
a. Although I will appreciate any help including alternative
suggestions, I would prefer if I can get some help with the function
I'm
currently using.
b. The function must work on a right-to-left format
document.
c. Speed is a very important factor, as I plan to use
the function to display the difference in a text box on a user form
that
will get updated every time a change is made to one of the columns.


Code:
--------------------

Function ColumnDiff()

Dim i As Integer, iCounter As Integer, iPos As Long, iPosCol As Long
Dim iCol() As Currency, nCol As Integer
Dim myRange As Range, iViewType As Integer, bEnd As Boolean

Const MaxDiff = 0 ' difference (in points) for the function to ignore

If Selection.StoryType 1 Then MsgBox "Cursor not in main text!": Exit

Function
Set myRange = Selection.Range
Application.ScreenUpdating = False
iViewType = ActiveWindow.View.Type: ActiveWindow.View.Type =
wdPrintView
iPos = -1
With Selection
.Collapse wdCollapseEnd
iCounter = iCounter + 1: StatusBar = iCounter
While iPos .Start
X2: iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 Then GoTo X0
ReDim iCol(Dialogs(wdDialogFormatColumns).Columns + 1)
iPosCol = iPos: iPos = iPos - 1: nCol = 0
While iPos .Start
iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 _
Or Dialogs(wdDialogFormatColumns).ColumnNo nCol _
Then GoTo X1
nCol = Dialogs(wdDialogFormatColumns).ColumnNo
iCol(nCol) = .Information(wdVerticalPositionRelativeToPage)
.GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
bEnd = True: iPos = ActiveDocument.StoryRanges(1).End
X1: For i = 1 To nCol ' iCol(0) = high peak
If iCol(0) iCol(i) Then iCol(0) = iCol(i)
Next i
iCol(nCol + 1) = iCol(0) ' iCol(nCol + 1) = low peak
For i = 1 To nCol
If iCol(nCol + 1) iCol(i) Then iCol(nCol + 1) = iCol(i)
Next i
If iCol(0) - iCol(nCol + 1) MaxDiff Then
.SetRange iPosCol, iPos
Application.ScreenUpdating = True
ColumnDiff = CCur(iCol(0) - iCol(i)) ' & "pt"
Exit Function
End If
If bEnd Then GoTo X3 Else GoTo X2
X0: .GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
End With
X3: myRange.Select
Application.ScreenUpdating = True: ActiveWindow.View.Type = iViewType
MsgBox "Done!"

End Function

--------------------


LIMITATIONS OF THE FUNCTION (NOT PROBLEMS!):
1. The function will only find the difference in the main text and not
in footnotes etc.
2. The function starts searching from the cursor location (or the end
of
the selected text) till the end of the document.


RELATED QUESTION:
http://tinyurl.com/7ju2puy


At the above url Macropad MVP has suggested several alternatives, as
mentioned there either the macro was too slow or I was not able to get
it to work in right-to-left format.

--
moishy
[/i][/color]




--
moishy


  #6   Report Post  
Posted to microsoft.public.word.pagelayout
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default Page Layout in multi-column documents

The underlying problem is that Word doesn't support "registry-true"
layout. However, if all text (body text as well as headings) have the
same, fixed, line spacing and spacing before set to an integer multiple
of the spacing, you'll get the best that can be accomplished in Word.

--
Stefan Blom
Microsoft Word MVP



On 2012-03-14 07:45 (GMT+1), moishy wrote:
Stefan,

Ideally your suggestion of using fixed line spacing is the right way to
go in setting up a new document, the trouble is I'm dealing with many
documents from many sources which cannot be counted upon to set up the
document properly.
Also, your suggestion won't help in case of a one line longer paragraph
on one side.
'Stefan Blom[_3_ Wrote:
;492085']Actually, Word does a fairly good job balancing columns when
the column ends
in a continuous section break. But note that it is not going to work if
the
columns contain a manual break somewhere.

However, if you are saying that you want the lines to match exactly
(across
columns), you will have to specify a fixed value for line spacing, and a

value for spacing before which is an integer multiple of the line
spacing.

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"moishy" wrote in message ...


Suzanne,

I do that, but it will not balance the columns accurately if one column
has more lines than the other, or if one column has more paragraphs
than
the other and spacing is used before or after the paragraphs.

I use macros kindly provided at http://tinyurl.com/7ju2puy

Suzanne S. Barnhill;492068 Wrote:-
Columns will be balanced if you insert a Continuous section break at
the
end
of the multi-column section.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org


"moishy" wrote in message

I've posted a question on http://tinyurl.com/6mflczk but it has
seemingly come to a dead end (i.e. no response).

Here's the issue I'm dealing with, page layout in multi-column
documents, since Word is not a desktop publishing solution, it doesn't
have a built-in option to align all columns equally at the bottom, and
therefore I have to do it manually. I'm using a function to find the
difference in points between two columns, the trouble is it doesn't
always work, sometimes it will return a value of several hundred
points
when there hardly is a difference at all.

I'm posting the function here; I would appreciate any help I can get
in
solving the mystery, and or improve the function.

Please note:
a. Although I will appreciate any help including alternative
suggestions, I would prefer if I can get some help with the function
I'm
currently using.
b. The function must work on a right-to-left format
document.
c. Speed is a very important factor, as I plan to use
the function to display the difference in a text box on a user form
that
will get updated every time a change is made to one of the columns.


Code:
--------------------

Function ColumnDiff()

Dim i As Integer, iCounter As Integer, iPos As Long, iPosCol As Long
Dim iCol() As Currency, nCol As Integer
Dim myRange As Range, iViewType As Integer, bEnd As Boolean

Const MaxDiff = 0 ' difference (in points) for the function to ignore

If Selection.StoryType 1 Then MsgBox "Cursor not in main text!": Exit

Function
Set myRange = Selection.Range
Application.ScreenUpdating = False
iViewType = ActiveWindow.View.Type: ActiveWindow.View.Type =
wdPrintView
iPos = -1
With Selection
.Collapse wdCollapseEnd
iCounter = iCounter + 1: StatusBar = iCounter
While iPos .Start
X2: iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 Then GoTo X0
ReDim iCol(Dialogs(wdDialogFormatColumns).Columns + 1)
iPosCol = iPos: iPos = iPos - 1: nCol = 0
While iPos .Start
iPos = .Start
If Dialogs(wdDialogFormatColumns).Columns = 1 _
Or Dialogs(wdDialogFormatColumns).ColumnNo nCol _
Then GoTo X1
nCol = Dialogs(wdDialogFormatColumns).ColumnNo
iCol(nCol) = .Information(wdVerticalPositionRelativeToPage)
.GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
bEnd = True: iPos = ActiveDocument.StoryRanges(1).End
X1: For i = 1 To nCol ' iCol(0) = high peak
If iCol(0) iCol(i) Then iCol(0) = iCol(i)
Next i
iCol(nCol + 1) = iCol(0) ' iCol(nCol + 1) = low peak
For i = 1 To nCol
If iCol(nCol + 1) iCol(i) Then iCol(nCol + 1) = iCol(i)
Next i
If iCol(0) - iCol(nCol + 1) MaxDiff Then
.SetRange iPosCol, iPos
Application.ScreenUpdating = True
ColumnDiff = CCur(iCol(0) - iCol(i)) '& "pt"
Exit Function
End If
If bEnd Then GoTo X3 Else GoTo X2
X0: .GoToNext wdGoToLine
iCounter = iCounter + 1: StatusBar = iCounter
Wend
End With
X3: myRange.Select
Application.ScreenUpdating = True: ActiveWindow.View.Type = iViewType
MsgBox "Done!"

End Function

--------------------


LIMITATIONS OF THE FUNCTION (NOT PROBLEMS!):
1. The function will only find the difference in the main text and not
in footnotes etc.
2. The function starts searching from the cursor location (or the end
of
the selected text) till the end of the document.


RELATED QUESTION:
http://tinyurl.com/7ju2puy


At the above url Macropad MVP has suggested several alternatives, as
mentioned there either the macro was too slow or I was not able to get
it to work in right-to-left format.

--
moishy
-





--
moishy




[/i][/color]
  #7   Report Post  
moishy moishy is offline
Junior Member
 
Posts: 4
Default

Any insights on the function I posted?
Quote:
Originally Posted by Stefan Blom[_3_] View Post
The underlying problem is that Word doesn't support "registry-true"
layout. However, if all text (body text as well as headings) have the
same, fixed, line spacing and spacing before set to an integer multiple
of the spacing, you'll get the best that can be accomplished in Word.

--
Stefan Blom
Microsoft Word MVP
  #8   Report Post  
Posted to microsoft.public.word.pagelayout
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default Page Layout in multi-column documents

For assistance with the VBA code, you should ask in a programming group or
forum.

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"moishy" wrote in message ...


Any insights on the function I posted?
'Stefan Blom[_3_ Wrote:
;492105']The underlying problem is that Word doesn't support
"registry-true"
layout. However, if all text (body text as well as headings) have the
same, fixed, line spacing and spacing before set to an integer multiple

of the spacing, you'll get the best that can be accomplished in Word.

--
Stefan Blom
Microsoft Word MVP





--
moishy


  #9   Report Post  
handeiere handeiere is offline
Junior Member
 
Posts: 10
Default

Quote:
Originally Posted by Stefan Blom[_3_] View Post
For assistance with the VBA code, you should ask in a programming group or
forum.

--
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"moishy" wrote in message ...


Any insights on the function I posted?
'Stefan Blom[_3_ Wrote:
;492105']The underlying problem is that Word doesn't support
"registry-true"
layout. However, if all text (body text as well as headings) have the
same, fixed, line spacing and spacing before set to an integer multiple

of the spacing, you'll get the best that can be accomplished in Word.

--
Stefan Blom
Microsoft Word MVP





--
moishy
Therefore it is important to include the details of the post to which you are replying, so newsreaders can interpret them correctly.

Last edited by handeiere : April 11th 12 at 11:02 AM
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-column pages. Need to leave 3rd column blank J Wilkes Microsoft Word Help 2 August 26th 08 05:34 PM
Embedding Multi-page Documents Pflugs Microsoft Word Help 6 May 2nd 07 11:56 PM
On 2 column page layout can I put page numbers on each column p00ts Microsoft Word Help 1 August 1st 05 05:05 PM
Breaking up multi-page document into several documents Chuck W Microsoft Word Help 2 March 18th 05 10:32 PM
multi page layout document questions Daniel Page Layout 1 January 28th 05 06:14 PM


All times are GMT +1. The time now is 08:51 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"