+ Reply to Thread
Results 1 to 6 of 6

<Parent> of the Clipboard

  1. #1
    Tim Childs
    Guest

    <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. #2
    K Dales
    Guest

    RE: <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. #3
    Tim Childs
    Guest

    Re: <Parent> of the Clipboard

    Hi

    many thanks for that helpful link and hints

    will try to assimilate

    Tim


    "K Dales" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #4
    Tim Childs
    Guest

    Re: <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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #5
    K Dales
    Guest

    Re: <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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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. #6
    Tim Childs
    Guest

    Re: <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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1