S
Stefan Haag
Hi
I'm using VBA to programmatically delete pages from a word document. The
original document is a word template and by using a form I'm choosing which
pages that should be deleted.
I'm using word2000 and everything works fine. I have also tested on
different computer using word2003.On some of thease computers everything
works fine but on some other computers the program crashes and i get the
following error message: "Run-time-Error '4608'. Value out of range".
Why is it working on some computers but dont work on other computers when
the same version of word is beeing used?
Here is the code row where the program crashes:
ActiveDocument.Range(lngStart, lngEnd).Delete
The code row is used in the following Sub:
Private Sub ShowLogo()
Dim lngStart As Long
Dim lngEnd As Long
If optionbutton60.Value = True Then
ActiveDocument.Tables(1).Delete
ActiveDocument.Tables(2).Delete
'remove pages
lngStart = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
1).Start
lngEnd = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
2).Start
ActiveDocument.Range(lngStart, lngEnd).Delete
lngStart = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
2).Start - 1
lngEnd = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
2).End
ActiveDocument.Range(lngStart, lngEnd).Delete
End If
End Sub
With regards
Stefan
I'm using VBA to programmatically delete pages from a word document. The
original document is a word template and by using a form I'm choosing which
pages that should be deleted.
I'm using word2000 and everything works fine. I have also tested on
different computer using word2003.On some of thease computers everything
works fine but on some other computers the program crashes and i get the
following error message: "Run-time-Error '4608'. Value out of range".
Why is it working on some computers but dont work on other computers when
the same version of word is beeing used?
Here is the code row where the program crashes:
ActiveDocument.Range(lngStart, lngEnd).Delete
The code row is used in the following Sub:
Private Sub ShowLogo()
Dim lngStart As Long
Dim lngEnd As Long
If optionbutton60.Value = True Then
ActiveDocument.Tables(1).Delete
ActiveDocument.Tables(2).Delete
'remove pages
lngStart = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
1).Start
lngEnd = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
2).Start
ActiveDocument.Range(lngStart, lngEnd).Delete
lngStart = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
2).Start - 1
lngEnd = ActiveDocument.Range.GoTo(wdGoToPage, wdGoToAbsolute,
2).End
ActiveDocument.Range(lngStart, lngEnd).Delete
End If
End Sub
With regards
Stefan