Word 2003 Works - Word XP Doesnt Work !!!! Argh

D

devo

Arrrghh

I got a problem on a template i designed for a friend to help him to does
timesheet.

I wrote it under word 2003 and he has word xp

I have had no problems with it under 2003... but get this error on the word
xp machine.

I am self taught programmer and it will be something i have done but cant
find enough infomation of why .

A brief description on the document is a

Template

3 tables

table 1 = date / contract
table 2 = enter the hours for each day
table 3 = a table which is within a frame (so it keep at the bottom of
the page) - prob could has used the footer..

table 3 = the caculation on the other data.

I know it works because it does on mine.

I know i am select the cell but not deleting it (only inserting data in to
each cell - technically an overwrite)

The error is 6028 cannot delete range

I spent a whole night trying to come close on figure on what to do or how to
do it..
I am novice programmer.. and quite happy to share the document..

The snippet of code where it falls over is below

Please help me....
This is the full routine and it falls over on the section i have labeled
with stars

Thanks..

Private Sub LWPCalculate()

Dim tblToUpdateHours As Word.Table
Dim tblToUpdateTotals As Word.Table

Dim intFirstUsableRow As Integer
Dim intRows As Integer
Dim intCols As Integer

Dim dblRowHours As Double
Dim dblTotalHours As Double

Dim dblVatRate As Double
Dim dblRatePerHour As Double
Dim dblNotDefaultRate As Double
Dim dblVatTotal As Double
Dim dblInvoiceTotal As Double
Dim dblCISdeduction As Double
Dim dblWagesTotal As Double

Dim strVatRate As String
Dim strHours As String

Application.ScreenUpdating = False

'Select the table

Set tblToUpdateHours = ActiveDocument.Tables(2)
Set tblToUpdateTotals = ActiveDocument.Tables(3)

With tblToUpdateHours

'Does table have a header row

intFirstUsableRow = 1
If .Rows.HeadingFormat Then
intFirstUsableRow = intFirstUsableRow + 2
End If

' Go Through Each Row

For intRows = intFirstUsableRow To .Rows.Count
For intCols = 2 To ((.Columns.Count) - 1)
strHours = Left$((.Cell(intRows, intCols).Range.Text),
Len(.Cell(intRows, intCols).Range.Text) - 2)
dblTotalHours = Val(dblTotalHours) + Val(strHours)
Next
.Cell(intRows, intCols).Range.Text = dblTotalHours
Next
End With

With tblToUpdateTotals

If IsNull(StrRatePerHour) = False Then
StrRatePerHour = 18
End If

dblRatePerHour = Val(StrRatePerHour)
dblVatRate = 0.175

dblWagesTotal = (dblTotalHours * dblRatePerHour)
dblCISdeduction = (dblWagesTotal * -0.18)
dblVatTotal = (dblWagesTotal * dblVatRate)

dblInvoiceTotal = (dblWagesTotal + dblCISdeduction)

'*******************************************
' Routines Falls over below at the writing of the data back.
**************************************'*****

.Cell(1, 2).Range.Text = dblTotalHours
.Cell(2, 2).Range.Text = FormatCurrency(dblRatePerHour, 2, vbTrue, vbFalse,
vbTrue)
.Cell(3, 2).Range.Text = FormatCurrency(dblWagesTotal, 2, vbTrue, vbFalse,
vbTrue)
.Cell(4, 2).Range.Text = FormatCurrency(dblCISdeduction, 2, vbTrue,
vbFalse, vbTrue)
.Cell(6, 2).Range.Text = FormatCurrency(dblVatTotal, 2, vbTrue, vbFalse,
vbTrue)
.Cell(5, 2).Range.Text = FormatCurrency(dblInvoiceTotal, 2, vbTrue,
vbFalse, vbTrue)


End With

' Move To Start Of Row On The Last Line Of Table

ActiveDocument.Tables(1).Rows(ActiveDocument.Tables(1).Rows.Count).Cells(1).Range.Select
Selection.Collapse wdCollapseStart

Application.ScreenRefresh
Application.ScreenUpdating = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top