Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default <Parent of the Clipboard

Hi

Is it possible to determine the source filename of the contents of the
clipboard.

The reason I ask is that I am writing a utility for others to use for
re-arranging data in the clipboard prior to pasting that re-arrangement and
some of the code is dependent on the information gleaned from the
spreadsheet which is sitting in the clipboard.

Put another way:
a) user selects data (from one of three files) - puts it in clipboard
b) user selects destination in different speadsheet
c) user runs procedure which manipulates data (incl code dependent on the
one of three files chosen) and pastes it at the activecell

Any help very welcome.

Tim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default <Parent of the Clipboard

You would need to use Windows API calls. Since the clipboard can hold
multiple items it is not straightforward unless you have a controlled
situation. The clipboard has an "owner" - per the documentation:
"In general, the clipboard owner is the window that last placed data in
clipboard."
(I love those "in general" qualifiers!)

But this only identifies the last app to have cut or copied data into the
clipboard. There are more advanced techniques involving creating and
registering your own clipboard formats that could be used, but would be very
advanced coding.

Full details:
http://msdn.microsoft.com/library/de.../clipboard.asp
--
- K Dales


"Tim Childs" wrote:

Hi

Is it possible to determine the source filename of the contents of the
clipboard.

The reason I ask is that I am writing a utility for others to use for
re-arranging data in the clipboard prior to pasting that re-arrangement and
some of the code is dependent on the information gleaned from the
spreadsheet which is sitting in the clipboard.

Put another way:
a) user selects data (from one of three files) - puts it in clipboard
b) user selects destination in different speadsheet
c) user runs procedure which manipulates data (incl code dependent on the
one of three files chosen) and pastes it at the activecell

Any help very welcome.

Tim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default <Parent of the Clipboard

Hi

many thanks for that helpful link and hints

will try to assimilate

Tim


"K Dales" wrote in message
...
You would need to use Windows API calls. Since the clipboard can hold
multiple items it is not straightforward unless you have a controlled
situation. The clipboard has an "owner" - per the documentation:
"In general, the clipboard owner is the window that last placed data in
clipboard."
(I love those "in general" qualifiers!)

But this only identifies the last app to have cut or copied data into the
clipboard. There are more advanced techniques involving creating and
registering your own clipboard formats that could be used, but would be

very
advanced coding.

Full details:

http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/dataexchange/clipboard.asp
--
- K Dales


"Tim Childs" wrote:



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default <Parent of the Clipboard

Hi

thanks for this

based on the link
http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/dataexchange/clipboard/clipboardreference/clipboardfun
ctions/enumclipboardformats.asp
which includes:
The GetClipboardOwner function retrieves the window handle of the current
owner of the clipboard.

Syntax

HWND GetClipboardOwner( VOID
);I wrote in a code module:

Option Explicit

Sub foo()
HWND GetClipboardOwner(VOID)
End Sub

I tried writing this at the top of the code module but the compiler said it
was invalid outside a procedure but it still had problems inside one too :)

Any help v welcome

Tim



"K Dales" wrote in message
...
You would need to use Windows API calls. Since the clipboard can hold
multiple items it is not straightforward unless you have a controlled
situation. The clipboard has an "owner" - per the documentation:
"In general, the clipboard owner is the window that last placed data in
clipboard."
(I love those "in general" qualifiers!)

But this only identifies the last app to have cut or copied data into the
clipboard. There are more advanced techniques involving creating and
registering your own clipboard formats that could be used, but would be

very
advanced coding.

Full details:

http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/dataexchange/clipboard.asp
--
- K Dales



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default <Parent of the Clipboard

OK, didn't know if you were familiar with Windows API. Win API is a library
of functions. They are not "standard" in VBA, so you have to tell VBA where
to find them and how to use them. The documentation you quote tells you that
the function result is a HWND which is a "windows handle" - a number (Long
integer) that windows uses to identify a particular window that is open. It
also tells you that the parameters are VOID - in other words, there are no
parameters. The API documentation also tells you what the "import library" is
- what file contains the function (all those .dll files on your computer are
libraries) - and in this case it is User32.dll, which should be in your
standard Windows path.

To declare a library function in VBA you do it like this:

Declare Function GetClipboardOwner Lib "user32" () As Long

Then you can use it as any other function in VBA. But the result is a
window handle. That may not be useful to you. See this reference about
handles, which includes code to find a window's title bar text if you have
its handle:
http://msdn.microsoft.com/library/de...inghandles.asp

For more on using the Windows API in general:
http://msdn.microsoft.com/library/de...rapibasics.asp

--
- K Dales


"Tim Childs" wrote:

Hi

thanks for this

based on the link
http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/dataexchange/clipboard/clipboardreference/clipboardfun
ctions/enumclipboardformats.asp
which includes:
The GetClipboardOwner function retrieves the window handle of the current
owner of the clipboard.

Syntax

HWND GetClipboardOwner( VOID
);I wrote in a code module:

Option Explicit

Sub foo()
HWND GetClipboardOwner(VOID)
End Sub

I tried writing this at the top of the code module but the compiler said it
was invalid outside a procedure but it still had problems inside one too :)

Any help v welcome

Tim



"K Dales" wrote in message
...
You would need to use Windows API calls. Since the clipboard can hold
multiple items it is not straightforward unless you have a controlled
situation. The clipboard has an "owner" - per the documentation:
"In general, the clipboard owner is the window that last placed data in
clipboard."
(I love those "in general" qualifiers!)

But this only identifies the last app to have cut or copied data into the
clipboard. There are more advanced techniques involving creating and
registering your own clipboard formats that could be used, but would be

very
advanced coding.

Full details:

http://msdn.microsoft.com/library/de...us/winui/winui
/windowsuserinterface/dataexchange/clipboard.asp
--
- K Dales






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default <Parent of the Clipboard

Hi

Thanks for coming back with more explanation which I'll try to assimilate -
I am certainly feel a lot closer with your help. (Up to now, I have used
some API's but they've pretty much been off the shelf!)

Best wishes

Tim


"K Dales" wrote in message
...
OK, didn't know if you were familiar with Windows API. Win API is a

library
of functions. They are not "standard" in VBA, so you have to tell VBA

where
to find them and how to use them. The documentation you quote tells you

that
the function result is a HWND which is a "windows handle" - a number

(Long
integer) that windows uses to identify a particular window that is open.

It
also tells you that the parameters are VOID - in other words, there are no
parameters. The API documentation also tells you what the "import library"

is
- what file contains the function (all those .dll files on your computer

are
libraries) - and in this case it is User32.dll, which should be in your
standard Windows path.

To declare a library function in VBA you do it like this:

Declare Function GetClipboardOwner Lib "user32" () As Long

Then you can use it as any other function in VBA. But the result is a
window handle. That may not be useful to you. See this reference about
handles, which includes code to find a window's title bar text if you have
its handle:

http://msdn.microsoft.com/library/de...us/modcore/htm
l/deovrunderstandinghandles.asp

For more on using the Windows API in general:

http://msdn.microsoft.com/library/de...us/modcore/htm
l/deovrapibasics.asp

--
- K Dales


"Tim Childs" wrote:



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
Where does Ms XL store the clipboard ? or where does MS Windowsstore clipboard ? Subu Setting up and Configuration of Excel 1 May 18th 09 06:56 AM
Clipboard empty but still get waring that clipboard is full Steve Excel Discussion (Misc queries) 0 June 17th 08 09:05 PM
ClearContents or ClearFormats also clears Clipboard. How can I keep the clipboard? [email protected] Excel Programming 5 December 16th 05 02:30 AM
Parent Folder Bruce Excel Programming 2 September 6th 05 03:40 AM
MultiPage Parent Name John Wilson Excel Programming 4 November 19th 04 02:42 PM


All times are GMT +1. The time now is 04:33 AM.

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

About Us

"It's about Microsoft Excel"