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 / January 2005

Tip: Looking for answers? Try searching our database.

word 2003 works - word xp doesnt --- arrrrghhhh

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
devo - 30 Dec 2004 19:29 GMT
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
Word Heretic - 03 Jan 2005 22:08 GMT
G'day "devo" <DONTdevoLIKE.ukSPAM@ntlworld.com>,

Try something friendlier like this:

Dim CellRange as Range

...

Set CellRange=.Cells(1,1).range
CellRange.moveend wdcharacter,-2
Cellrange.insertafter MyCalculations

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

devo reckoned:

>Arrrghh
>
[quoted text clipped - 134 lines]
>
>End Sub
devo - 04 Jan 2005 22:36 GMT
thanks steve... will give it a go... and let you know....

i am trying to use too complex code or just badly written code ....

i thought there would be no difference between 2003 / office xp...

many thanks

nick
> G'day "devo" <DONTdevoLIKE.ukSPAM@ntlworld.com>,
>
[quoted text clipped - 157 lines]
>>
>>End Sub
Word Heretic - 05 Jan 2005 09:28 GMT
G'day "devo" <DONTdevoLIKE.ukSPAM@ntlworld.com>,

The worst one I have found is the ability of the user to keep on
'editing' during macro execution. This means we assign selection to a
range and the active doc to a document ASAP and NEVER refer to those
entities AGAIN!

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

devo reckoned:

>thanks steve... will give it a go... and let you know....
>
[quoted text clipped - 166 lines]
>>>
>>>End Sub

Rate this thread:






 
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.