Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When will VFP7 SP1 come out?
Message
From
05/11/2001 16:12:43
 
 
To
05/11/2001 15:38:54
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00577318
Message ID:
00577605
Views:
28
>How about a decent response to this query? I could understand it if my problem was on the periphery of obscurity and only affected one in a million developers. However, this problem is, well, pretty basic.

We know about an Outlook automation issue concerning a fatal exception using FOR EACH to traverse the folders collection, which Gary Beasley reported here. If you are doing something similar to this, you could code without the FOR EACH.

Here is Gary's posted code which I modified very slightly to work in my configuration. I added the IF structure to show with FOR EACH and FOR. Flip the IF .T. to IF .F. to reproduce the original crash with FOR EACH. With FOR, it works fine.
oOutlook = CREATEOBJECT('outlook.application')
loSpace = oOutlook.GetNameSpace("MAPI")
m.OLSyncFolder = "Inbox"
loSelFolder = .NULL.

IF .T.
	FOR lni = 1 TO loSpace.Folders.COUNT
		loFolder = loSpace.Folders.ITEM(lni)
		FOR lnj = 1 TO loFolder.Folders.COUNT
			loSubFolder = loFolder.Folders.ITEM(lnj)
			IF ALLT(loSubFolder.NAME) == m.OLSyncFolder
				loSelFolder = loSubFolder
				EXIT
			ENDIF
		ENDFOR
		IF !ISNULL(loSelFolder)
			EXIT
		ENDIF
	ENDFOR
ELSE
	FOR EACH loFolder IN loSpace.Folders
		FOR EACH loSubFolder IN loFolder.Folders
			IF ALLT(loSubFolder.NAME) == m.OLSyncFolder
				loSelFolder = loSubFolder
				EXIT
			ENDIF
		ENDFOR
		IF !ISNULL(loSelFolder)
			EXIT
		ENDIF
	ENDFOR
ENDIF
IF ISNULL(loSelFolder)
	=MESSAGEBOX("Folder '" + m.OLSyncFolder + "' is invalid or not found.",48,"System Message")
	RETURN
ENDIF

IF TYPE("loSelfolder")<>"O"
	=MESSAGEBOX("Invalid folder selected",48, "Sync Error!" )
	RETURN
ENDIF

loContacts = loSelFolder.Items
RETURN
If you are seeing something unrelated to FOR EACH, you would need to give additional info to enable me to reproduce the problem so we can get it sorted out.

I hope this helps!
Jim Saunders
Microsoft
This posting is provided “AS IS”, with no warranties, and confers no rights.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform