Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel paste special
Message
From
17/03/2006 11:04:20
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Excel paste special
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01105324
Message ID:
01105324
Views:
125
Sometimes I'm getting this message:

"OLE IDispatch exception code 0 from Microsoft Excel: Unable to get the PasteSpecial property of the Range class..(nr 1429)"

It just happens once in a couple of weeks. Meanwhile the whole thing works flawlessly, even producing huge sheets.

The piece of code where this happens is where I paste the contents of clipboard as created by _vfp.datatoclip(,,3) with the first line removed. The target range is a named range, two rows high initially, where a sufficient number of lines is inserted between these two just prior to pasting.

It's Office 2003 (though I can't really be sure it isn't Office 2000 on some workstations - but then this works 99.9% of the time).

Any idea what may cause this?

here's the code:
	Procedure PasteToRange(cCRS,cRange,lOverwrite)
*-- dn 11/08/04
...[some parameter checking here]
		c=_Cliptext
		_vfp.DataToClip(,,3)
* remove first line from clipboard, contains column names
*[2005/07/14 17:47:45] dragan - need memowidth wide enough
		N=Set("Memowidth")
		Set Memowidth To 1023
		_Cliptext=Strtran(_Cliptext, Mline(_Cliptext,1)+hCR,"")
		Set Memowidth To N

*-- insert blank lines in worksheet
		oXls= This.oApp
		oRng1 = oXls.Range(cRange)
		nRows= Reccount(cCRS)
		If Reccount(cCRS) > 1 And !lOverwrite
			oXls.Application.CutCopyMode = .T.
			oRng = oXls.Range(oXls.Cells(oRng1.Row + 1, 1),;
			   oXls.Cells(oRng1.Row + nRows - 1, 1))
			oRng.EntireRow.Insert
			oRng = Null
		Endif
...
*-- copy records from clipboard to worksheet.range
		oRng1.Select()
		oXls.Selection.PasteSpecial()       && here it happens, sometimes.
*-- restore original clipboard
		_Cliptext=c
...

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Next
Reply
Map
View

Click here to load this message in the networking platform