Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I paste from clipboard to range using Excel VBA

I have just moved from Windows 2000 & Office 2002 (Old) to XP Pro and Office
2003 (New). The following statements work in the old version and also in
the new version when I step through the code using the debugger. They fail
when I try and run the macro in the new version.

Code:
Dim oSheet As Worksheet
' copy text to windows clipboard
oSheet.Paste
' error generated on the above stating "Paste method of Worksheet Class
failed."
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How do I paste from clipboard to range using Excel VBA

Did you set osheet to the correct sheet?

Was that sheet protected?

Any chance you ran something that cleared the clipboard?

maybe:

if application.cutcopymode = false then
msgbox "nothing to paste"
else
osheet.paste
end if

If none of this helped, you'll have to include some more details.

Beesagood wrote:

I have just moved from Windows 2000 & Office 2002 (Old) to XP Pro and Office
2003 (New). The following statements work in the old version and also in
the new version when I step through the code using the debugger. They fail
when I try and run the macro in the new version.

Code:
Dim oSheet As Worksheet
' copy text to windows clipboard
oSheet.Paste
' error generated on the above stating "Paste method of Worksheet Class
failed."


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I paste from clipboard to range using Excel VBA

Yes, the cutcopymode returns false. But when when it breaks, I step through
the debugger, the data gets copied from the clipboard, so it is there.

The data is copied to the clipboard by using a DDE command to the
"Bloomberg" application to copy the screen contents to the windows clipboard.
This instruction doesn't appear to notify the XP operating system that the
data is there. When it breaks and I step through, the XP operating system
then is able to find the data on the clipboard.

I will try and access the API directly (although I haven't had to do this
before) and debug.print as much info as I can to find this data when I run
the VBA in real-time. Thanks for your pointer and any more comments would be
appreciated. Thanks.

"Dave Peterson" wrote:

Did you set osheet to the correct sheet?

Was that sheet protected?

Any chance you ran something that cleared the clipboard?

maybe:

if application.cutcopymode = false then
msgbox "nothing to paste"
else
osheet.paste
end if

If none of this helped, you'll have to include some more details.

Beesagood wrote:

I have just moved from Windows 2000 & Office 2002 (Old) to XP Pro and Office
2003 (New). The following statements work in the old version and also in
the new version when I step through the code using the debugger. They fail
when I try and run the macro in the new version.

Code:
Dim oSheet As Worksheet
' copy text to windows clipboard
oSheet.Paste
' error generated on the above stating "Paste method of Worksheet Class
failed."


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How do I paste from clipboard to range using Excel VBA

I've never used any DDE stuff.

I don't have any other guesses.

Beesagood wrote:

Yes, the cutcopymode returns false. But when when it breaks, I step through
the debugger, the data gets copied from the clipboard, so it is there.

The data is copied to the clipboard by using a DDE command to the
"Bloomberg" application to copy the screen contents to the windows clipboard.
This instruction doesn't appear to notify the XP operating system that the
data is there. When it breaks and I step through, the XP operating system
then is able to find the data on the clipboard.

I will try and access the API directly (although I haven't had to do this
before) and debug.print as much info as I can to find this data when I run
the VBA in real-time. Thanks for your pointer and any more comments would be
appreciated. Thanks.

"Dave Peterson" wrote:

Did you set osheet to the correct sheet?

Was that sheet protected?

Any chance you ran something that cleared the clipboard?

maybe:

if application.cutcopymode = false then
msgbox "nothing to paste"
else
osheet.paste
end if

If none of this helped, you'll have to include some more details.

Beesagood wrote:

I have just moved from Windows 2000 & Office 2002 (Old) to XP Pro and Office
2003 (New). The following statements work in the old version and also in
the new version when I step through the code using the debugger. They fail
when I try and run the macro in the new version.

Code:
Dim oSheet As Worksheet
' copy text to windows clipboard
oSheet.Paste
' error generated on the above stating "Paste method of Worksheet Class
failed."


--

Dave Peterson



--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I paste from clipboard to range using Excel VBA

It appears that the XP operating system required my Excel VBA aaplication to
explicitly activate itself (although Windows 200 did not require this!). The
following code worked in XP:

AppActivate Application.Name
oSheet.Paste

"Dave Peterson" wrote:

I've never used any DDE stuff.

I don't have any other guesses.

Beesagood wrote:

Yes, the cutcopymode returns false. But when when it breaks, I step through
the debugger, the data gets copied from the clipboard, so it is there.

The data is copied to the clipboard by using a DDE command to the
"Bloomberg" application to copy the screen contents to the windows clipboard.
This instruction doesn't appear to notify the XP operating system that the
data is there. When it breaks and I step through, the XP operating system
then is able to find the data on the clipboard.

I will try and access the API directly (although I haven't had to do this
before) and debug.print as much info as I can to find this data when I run
the VBA in real-time. Thanks for your pointer and any more comments would be
appreciated. Thanks.

"Dave Peterson" wrote:

Did you set osheet to the correct sheet?

Was that sheet protected?

Any chance you ran something that cleared the clipboard?

maybe:

if application.cutcopymode = false then
msgbox "nothing to paste"
else
osheet.paste
end if

If none of this helped, you'll have to include some more details.

Beesagood wrote:

I have just moved from Windows 2000 & Office 2002 (Old) to XP Pro and Office
2003 (New). The following statements work in the old version and also in
the new version when I step through the code using the debugger. They fail
when I try and run the macro in the new version.

Code:
Dim oSheet As Worksheet
' copy text to windows clipboard
oSheet.Paste
' error generated on the above stating "Paste method of Worksheet Class
failed."

--

Dave Peterson



--

Dave Peterson




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How do I paste from clipboard to range using Excel VBA

Glad you posted back with your fix--now google knows!

Beesagood wrote:

It appears that the XP operating system required my Excel VBA aaplication to
explicitly activate itself (although Windows 200 did not require this!). The
following code worked in XP:

AppActivate Application.Name
oSheet.Paste

"Dave Peterson" wrote:

I've never used any DDE stuff.

I don't have any other guesses.

Beesagood wrote:

Yes, the cutcopymode returns false. But when when it breaks, I step through
the debugger, the data gets copied from the clipboard, so it is there.

The data is copied to the clipboard by using a DDE command to the
"Bloomberg" application to copy the screen contents to the windows clipboard.
This instruction doesn't appear to notify the XP operating system that the
data is there. When it breaks and I step through, the XP operating system
then is able to find the data on the clipboard.

I will try and access the API directly (although I haven't had to do this
before) and debug.print as much info as I can to find this data when I run
the VBA in real-time. Thanks for your pointer and any more comments would be
appreciated. Thanks.

"Dave Peterson" wrote:

Did you set osheet to the correct sheet?

Was that sheet protected?

Any chance you ran something that cleared the clipboard?

maybe:

if application.cutcopymode = false then
msgbox "nothing to paste"
else
osheet.paste
end if

If none of this helped, you'll have to include some more details.

Beesagood wrote:

I have just moved from Windows 2000 & Office 2002 (Old) to XP Pro and Office
2003 (New). The following statements work in the old version and also in
the new version when I step through the code using the debugger. They fail
when I try and run the macro in the new version.

Code:
Dim oSheet As Worksheet
' copy text to windows clipboard
oSheet.Paste
' error generated on the above stating "Paste method of Worksheet Class
failed."

--

Dave Peterson



--

Dave Peterson



--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot paste between 2 excel spreadsheets w/o office clipboard ope bluecali Excel Discussion (Misc queries) 1 May 11th 07 01:13 PM
Unable to copy/paste in Excel once clipboard gets full Sean via OfficeKB.com Excel Discussion (Misc queries) 0 April 26th 06 11:43 PM
how do I paste formulas in excel clipboard? AndyBermuda Excel Discussion (Misc queries) 3 May 27th 05 03:25 PM
clipboard in Excel collects but will only paste most recent item Gregory1558 Excel Discussion (Misc queries) 1 May 17th 05 06:35 PM
Paste Clipboard from Word to last row in excel Otto Moehrbach[_3_] Excel Programming 1 July 23rd 03 03:30 PM


All times are GMT +1. The time now is 07:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"