Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Where does Ms XL store the clipboard ? or where does MS Windowsstore clipboard ? | Setting up and Configuration of Excel | |||
Clipboard empty but still get waring that clipboard is full | Excel Discussion (Misc queries) | |||
ClearContents or ClearFormats also clears Clipboard. How can I keep the clipboard? | Excel Programming | |||
Parent Folder | Excel Programming | |||
MultiPage Parent Name | Excel Programming |