Mike Lewis
Programmer
Several of my applications have "suddenly" developed a bug which I can't explain.
It always occurs when I try to loop through a collection in a COM server using FOR EACH ... ENDFOR.
To give a simple example:
I've got this sort of code in many places in my apps, and it has always worked. But now, I am getting an error that says that the property (Sentences in this example) cannot be found.
The funny thing is that, if I replace the code with the following:
that works perfectly.
I'm not aware of any change I've made to my system that could have caused this to happen.
Some further details:
- It happens consistently with all Office apps (Word, Outlook, Excel, etc).
- It happens on two different computers; one has Office 2000, the other has Office 2007.
- The error message is a native VFP message, not an OLE message.
- On both machines, I am running VFP 9.0 SP1.
- I don't see the problem when using native VFP collections.
What am I missing? Am I going ga-ga? I hope someone can help.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
My Visual FoxPro site: www.ml-consult.co.uk
It always occurs when I try to loop through a collection in a COM server using FOR EACH ... ENDFOR.
To give a simple example:
Code:
* oDoc is an object ref to a Word document
FOR EACH ox IN oDoc.Sentences
? ox.text
ENDFOR
I've got this sort of code in many places in my apps, and it has always worked. But now, I am getting an error that says that the property (Sentences in this example) cannot be found.
The funny thing is that, if I replace the code with the following:
Code:
FOR lnI = 1 TO oDoc.Sentences.Count
ox = oDoc.Sentences(lnI)
? ox.Text
ENDFOR
that works perfectly.
I'm not aware of any change I've made to my system that could have caused this to happen.
Some further details:
- It happens consistently with all Office apps (Word, Outlook, Excel, etc).
- It happens on two different computers; one has Office 2000, the other has Office 2007.
- The error message is a native VFP message, not an OLE message.
- On both machines, I am running VFP 9.0 SP1.
- I don't see the problem when using native VFP collections.
What am I missing? Am I going ga-ga? I hope someone can help.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
My Visual FoxPro site: www.ml-consult.co.uk