ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem in PasteSpecial function (https://www.excelbanter.com/excel-programming/330830-problem-pastespecial-function.html)

ojas_maru

Problem in PasteSpecial function
 

I everyone this is my first port in this forum
I m facing a weird problem
I have following code written in VBA

Dim Source As Range
Target.*Copy*
Set Source = Application.Worksheets("Sheet2").Range("$A$1,$A$3" )
Source.*PasteSpecial* xlPasteAll, xlPasteSpecialOperationNone
Target.Select

This works perfectly fine

And when i write the same code in VC++ (Excel com addin)
paste special just throws me into catch block
More if my rangeptr contains more than one cell then it says ki merge
cell should of equal size ?? (None of my cells are merged in tha
range

--
ojas_mar
-----------------------------------------------------------------------
ojas_maru's Profile: http://www.msusenet.com/member.php?userid=184
View this thread: http://www.msusenet.com/t-187050837


KL

Problem in PasteSpecial function
 
Hi,

This probably doesn't answer your question, but I guess your VBA code can be
shortened dramatically:

1) If you want just values:

Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("Sheet2").Range("$A$1,$A$3") = Target
End Sub

2) If you want to paste all:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Copy Sheets("Sheet2").Range("$A$1,$A$3")
End Sub

Reagards,
KL


"ojas_maru" wrote in message
...

I everyone this is my first port in this forum
I m facing a weird problem
I have following code written in VBA

Dim Source As Range
Target.*Copy*
Set Source = Application.Worksheets("Sheet2").Range("$A$1,$A$3" )
Source.*PasteSpecial* xlPasteAll, xlPasteSpecialOperationNone
Target.Select

This works perfectly fine

And when i write the same code in VC++ (Excel com addin)
paste special just throws me into catch block
More if my rangeptr contains more than one cell then it says ki merged
cell should of equal size ?? (None of my cells are merged in that
range)


--
ojas_maru
------------------------------------------------------------------------
ojas_maru's Profile: http://www.msusenet.com/member.php?userid=1849
View this thread: http://www.msusenet.com/t-1870508372




ojas_maru[_2_]

Problem in PasteSpecial function
 

Well my aim is get it working in VC++
I dont know why pastespecial throws me in catch block.
I tried even the following statments.


pSourcePtr-GetApplication()-PutCutCopyMode(0, xlCopy);

I guess i need to set some parameter before calling paste special

--
ojas_mar
-----------------------------------------------------------------------
ojas_maru's Profile: http://www.msusenet.com/member.php?userid=184
View this thread: http://www.msusenet.com/t-187050837



All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com