when I run the code below I get the run time error 287
application-defined or object-defined error
whats causing this error i cant figure it out
I just change to windows xp from 98 and this ran fine on the other machine
so can someone point me in the right direction
many thanks Phil
Private Sub cbroo_main_Change()
Dim sourcedoc As Document, i As Long, myitem As Range
cbroo_profile.Clear
Set sourcedoc = GetObject("c:\schedule\supplier\roofing.doc")
For i = 1 To sourcedoc.Tables(1).Cell(cbroo_main.ListIndex + 2,
2).Range.Paragraphs.Count
Set myitem = sourcedoc.Tables(1).Cell(cbroo_main.ListIndex + 2,
2).Range.Paragraphs(i).Range
myitem.End = myitem.End - 1
cbroo_profile.AddItem myitem.Text
Next i
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End Sub
Private Sub UserForm_Initialize()
Dim sourcedoc As Document, i As Long, myitem As Range
Set sourcedoc = GetObject("c:\schedule\supplier\roofing.doc")
For i = 2 To sourcedoc.Tables(1).Rows.Count
Set myitem = sourcedoc.Tables(1).Cell(i, 1).Range
myitem.End = myitem.End - 1
cbroo_main.AddItem myitem.Text
Next i
End Sub
Private Sub cbroo_profile_Change()
cbroo_thickness.Clear
Dim sourcedoc As Document, i As Long, myitem As Range
If cbroo_profile.ListIndex >= 0 Then
Set sourcedoc = GetObject("c:\schedule\supplier\roofing.doc")
Set myitem = sourcedoc.Tables(1).Cell(cbroo_main.ListIndex + 2,
3).Range.Paragraphs(cbroo_profile.ListIndex + 1).Range
cbroo_thickness.List = Split(myitem, ",")
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End If
End Sub
Word Heretic - 17 Dec 2004 12:33 GMT
G'day "Phil",
Set SourceDoc = Documents.Open("c:\schedule\supplier\roofing.doc")
etc
No comments, some strange code decisions.
Steve Hudson - Word Heretic
steve from wordheretic.com (Email replies require payment)
Without prejudice
"Phil" <phespe remove this bigpond.net.au> reckoned:
> Set sourcedoc = GetObject("c:\schedule\supplier\roofing.doc")