PC Review


Reply
Thread Tools Rate Thread

Automation AddIn (UDF) in C# not able to manipulate XL Objects...

 
 
pdxJaxon
Guest
Posts: n/a
 
      16th Jul 2008
I'm having a lot of trouble manipulating XL objects from my AddIn code (A C#
Automation AddIin that serves as a UDF).

I Can:
Read Cell Valules
Insert Comments Into Cells
Call Replace() Functions on Cells\Ranges
Obtain Handles to Ranges
Various other things

I CANNOT:
Insert Data directly into a cell (without using Replace function)
Insert Rows
Paste Data Into a Range

The sheet is NOT protected


Here is a line that does nothing (no error message at all)
range.EntireRow.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, m);


another ugly example:
rCml.Select();
rCml.Copy(m);
range.Select();

range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll,Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, false, false);


again, no error message, but no result either....

this is becoming critical.

thanks for any help you can offer.



--
Cheers,

Gregory A Jackson
Portland, OR
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      16th Jul 2008
Excel UDF's (in any language) cannot change the worksheet they're in, only
return a value (or array of values).

Tim


"pdxJaxon" <(E-Mail Removed)> wrote in message
news:ED86159A-9AFF-4105-9704-(E-Mail Removed)...
> I'm having a lot of trouble manipulating XL objects from my AddIn code (A
> C#
> Automation AddIin that serves as a UDF).
>
> I Can:
> Read Cell Valules
> Insert Comments Into Cells
> Call Replace() Functions on Cells\Ranges
> Obtain Handles to Ranges
> Various other things
>
> I CANNOT:
> Insert Data directly into a cell (without using Replace function)
> Insert Rows
> Paste Data Into a Range
>
> The sheet is NOT protected
>
>
> Here is a line that does nothing (no error message at all):
> range.EntireRow.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown,
> m);
>
>
> another ugly example:
> rCml.Select();
> rCml.Copy(m);
> range.Select();
>
> range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll,Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone,
> false, false);
>
>
> again, no error message, but no result either....
>
> this is becoming critical.
>
> thanks for any help you can offer.
>
>
>
> --
> Cheers,
>
> Gregory A Jackson
> Portland, OR



 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      16th Jul 2008
Gregory,

In your Insert example, I believe the 2nd argument is the CopyOrigin, which
looks like it's either "xlFormatFromLeftOrAbove" or
"xlFormatFromRightOrBelow". It is not the value that you are pasting. In
order to paste a row with the Insert, you'd have done something like this in
the previous line of code:

range("A1").EntireRow.Copy

In the PasteSpecial example I believe Copy(m) clears the clipboard. In
other words it should copy m into rCml, but then there is nothing to
PasteSpecial. I get an error message running this in Excel though, so
something is different.

Also "range" is an Excel reserved word, so I'd rename that variable.

hth,

Doug

"pdxJaxon" <(E-Mail Removed)> wrote in message
news:ED86159A-9AFF-4105-9704-(E-Mail Removed)...
> I'm having a lot of trouble manipulating XL objects from my AddIn code (A
> C#
> Automation AddIin that serves as a UDF).
>
> I Can:
> Read Cell Valules
> Insert Comments Into Cells
> Call Replace() Functions on Cells\Ranges
> Obtain Handles to Ranges
> Various other things
>
> I CANNOT:
> Insert Data directly into a cell (without using Replace function)
> Insert Rows
> Paste Data Into a Range
>
> The sheet is NOT protected
>
>
> Here is a line that does nothing (no error message at all):
> range.EntireRow.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown,
> m);
>
>
> another ugly example:
> rCml.Select();
> rCml.Copy(m);
> range.Select();
>
> range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll,Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone,
> false, false);
>
>
> again, no error message, but no result either....
>
> this is becoming critical.
>
> thanks for any help you can offer.
>
>
>
> --
> Cheers,
>
> Gregory A Jackson
> Portland, OR



 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      16th Jul 2008
Oh yeah, that too

Doug

"Tim Williams" <timjwilliams at gmail dot com> wrote in message
news:%(E-Mail Removed)...
> Excel UDF's (in any language) cannot change the worksheet they're in, only
> return a value (or array of values).
>
> Tim
>
>
> "pdxJaxon" <(E-Mail Removed)> wrote in message
> news:ED86159A-9AFF-4105-9704-(E-Mail Removed)...
>> I'm having a lot of trouble manipulating XL objects from my AddIn code (A
>> C#
>> Automation AddIin that serves as a UDF).
>>
>> I Can:
>> Read Cell Valules
>> Insert Comments Into Cells
>> Call Replace() Functions on Cells\Ranges
>> Obtain Handles to Ranges
>> Various other things
>>
>> I CANNOT:
>> Insert Data directly into a cell (without using Replace function)
>> Insert Rows
>> Paste Data Into a Range
>>
>> The sheet is NOT protected
>>
>>
>> Here is a line that does nothing (no error message at all):
>> range.EntireRow.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown,
>> m);
>>
>>
>> another ugly example:
>> rCml.Select();
>> rCml.Copy(m);
>> range.Select();
>>
>> range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll,Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone,
>> false, false);
>>
>>
>> again, no error message, but no result either....
>>
>> this is becoming critical.
>>
>> thanks for any help you can offer.
>>
>>
>>
>> --
>> Cheers,
>>
>> Gregory A Jackson
>> Portland, OR

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to manipulate chart objects in PPT2007-SP2 John Svendsen Microsoft Powerpoint 1 8th Jun 2009 10:21 PM
Using Macros to manipulate drawn objects =?Utf-8?B?RWxsaW90?= Microsoft Excel Misc 0 24th May 2007 03:13 PM
Unshimmed Automation Addin and Shimmed COM Addin in same App Domai =?Utf-8?B?QnJhbmRvbg==?= Microsoft Excel Programming 0 27th Jun 2006 11:18 PM
How can I manipulate Embeded Objects? =?Utf-8?B?R2FyeQ==?= Microsoft Access VBA Modules 1 23rd Mar 2006 11:16 PM
Addin will not load when I pass Interop Outlook objects to objects to ctors outside the addin Ben MacLeod Microsoft Outlook Interoperability 0 18th Aug 2004 03:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 PM.