![]() |
|
|
|
#1
|
|||
|
|||
|
Looks like I spoke too soon.
When processing with frequent "Stop" commands to check all is working, my code runs perfectly. However, when running end-to-end it loops/freezes (i.e. it becomes unresponsive and I have to use Task Manager to dismis Word). I've had similar issues with Excel in the past, where some functions need the VBA to be paused to allow the system to catch up. Is this a known issue with Range.Information? (Note: My personal variable naming convention means that any variable starting with "g" is declared globally in a separate "Globals" module) In my document formatting I use the following code, which recovers the horizontal end points for each column:- Code:
Public Sub SetColsInWholeDoc(intCols As Integer)
'#######################################
'# Set the required number of columns. #
'# N.B. The numcolumns parameter seems #
'# to be the EXTRA columns (above #
'# the basic 1), so we subtract #
'# 1 from the User's specified #
'# column count. #
'#######################################
'*
'** Check it's a valid request.
'*
If intCols < 2 Then Exit Sub
'*
'** Now set the required column count.
'*
With Selection.Sections(1)
With .PageSetup.TextColumns
.SetCount NumColumns:=intCols - 1
.Add Spacing:=InchesToPoints(0.25), _
EvenlySpaced:=True
End With
glngColWidth = .PageSetup.TextColumns(1).width
gsngColWInches = PointsToInches(glngColWidth)
' MsgBox glngColWidth & " pts, " & gsngColWInches & " inches"
End With
'*
'** Set up horizontal end point of
'** of each page column.
'*
glngCol1HEnd = glngColWidth
Select Case intCols
Case 1
glngCol2HEnd = 0
glngCol3HEnd = 0
Case 2
glngCol2HEnd = glngColWidth * 2
glngCol3HEnd = 0
Case 3
glngCol2HEnd = glngColWidth * 2
glngCol3HEnd = glngColWidth * 3
End Select
End Sub 'SetColsInWholeDocc
Code:
Public Function funGetCurPageCol(rng As Range) As Long
Dim lngH As Long
lngH = rng.Information(wdHorizontalPositionRelativeToPage)
Select Case True
Case lngH <= glngCol1HEnd
funGetCurPageCol = 1
Case lngH > glngCol1HEnd And _
lngH <= glngCol2HEnd
funGetCurPageCol = 2
Case lngH > glngCol2HEnd
funGetCurPageCol = 3
End Select
End Function 'funGetCurPageCol
|
|
| Tags |
| columns, count, information |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Return nameof Left column in current view
|
trevorc | Excel Programming | 7 | 09-19-2018 08:38 PM |
Table adding cells to previous page with room still on current page.
|
gedet | Word | 1 | 01-03-2018 10:35 AM |
| Identify last blank cell in column | mbesspiata | Excel | 0 | 02-27-2015 11:29 AM |
| How to save the current page in a new file with all the page settings (header, footer | Jamal NUMAN | Word | 6 | 03-15-2012 03:27 PM |
| Is there a way to automatically highlight the column and the row that of the current | Jamal NUMAN | Excel | 8 | 02-14-2012 02:58 PM |