Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Alan[_6_] Alan[_6_] is offline
external usenet poster
 
Posts: 23
Default Help! with Single precision Issue

When calling the code found below I often get a runtime error # 4608
(Value out of range). I believe it has something to do with a
precision problem, but I do not understand why I am getting it, as all
the variables are Singles.

Also, when I set a cell width, it does not always change it to the
exact value I want.

The code is running in Excel but manipulating a Word document.

Thanks in Advance, Alan

Sub FixBDtableWidth()
Dim matchWidth As Single, currWidth As Single, delta As Single
Dim LastCellWidth As Single, Next2LastCellWidth As Single
With Word.ActiveDocument.Tables(2)
matchWidth = TotalRowWidth(2, 1)
Debug.Print "matchWidth = " & matchWidth
.Cell(2, 1).Width = 72
.Cell(2, 2).Width = 72
currWidth = TotalRowWidth(2, 2)
delta = currWidth - matchWidth
LastCellWidth = .Cell(2, 12).Width
If currWidth matchWidth Then
If (LastCellWidth delta) Then
.Cell(2, 12).Width = LastCellWidth - delta
Else
.Cell(2, 12).Width = 5
End If
End If
End With
End Sub

Function TotalRowWidth(TableNum As Integer, RowNum As Long) As Single
Dim aCell As Word.Cell
TotalRowWidth = 0
On Error GoTo SafeExit
With Word.ActiveDocument
For Each aCell In .Tables(TableNum).Rows(RowNum).Cells
TotalRowWidth = TotalRowWidth + aCell.Width
Next aCell
End With
Exit Function
SafeExit:
Set aCell = Nothing
TotalRowWidth = 0
End Function
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
calculations, precision in word Shawn O'Connor Microsoft Word Help 3 November 1st 07 01:10 PM
MS fix for this issue [email protected] Formatting Long Documents 0 August 31st 07 05:08 PM
How can a single document have a single style with different fonts and sizes? John Dalberg Microsoft Word Help 7 March 17th 07 06:57 AM
Change color of precision selector from white in text box select? skeptic007 Microsoft Word Help 2 October 12th 06 02:24 PM
OLE Issue sumtop Microsoft Word Help 1 March 15th 05 09:11 AM


All times are GMT +1. The time now is 06:35 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"