Results 1 to 23 of 23

Thread: clipboard activex for vba, vbs etc

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    clipboard activex for vba, vbs etc

    i am posting an activex dll to simplify the clipboard usage for vba or any script language without clipboard object

    hope it may be useful to someone

    usage add a reference or createobject("clipbrd.clipboard")
    has same methods as vb6 clipboard object

    .settext text : returns boolean, true on success
    .gettext : returns string
    .clear : returns boolean
    .setdata object, format : format is optional clipboard format, returns boolean
    .getdata(format) : returns object
    format parameter is optional and should be a clipboard constant value
    Constant Value Description
    vbCFBitmap 2 Bitmap (.bmp files)
    vbCFMetafile 3 Metafile (.wmf files)
    vbCFDIB 8 Device-independent bitmap (DIB)
    vbCFPalette 9 Color palette
    Note the constants i copied from msdn may not all be correct, or are outdated, see
    http://msdn.microsoft.com/en-us/library/ebwdx8yh.aspx


    sample
    vb Code:
    1. Set myclip = CreateObject("clipbrd.clipboard")
    2. SavePicture myclip.GetData(2), "C:\test\clippic.bmp"

    to use unzip and register

    vb6 source available if anyone wants
    Attached Files Attached Files
    Last edited by westconn1; Oct 13th, 2009 at 09:33 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: clipboard activex for vba, vbs etc

    Pete, I would love to see the source...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: clipboard activex for vba, vbs etc

    Tested it with bmp. Works perfectly nice one pete

    and thanks for the source...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4
    New Member
    Join Date
    Oct 2009
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    Hello, could I have the source please? I've been looking for something like this for a while. Many thanks in advance.

  5. #5
    New Member
    Join Date
    Oct 2009
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    I have a question: I tried it in powerpoint but I can't copy shapes.
    If I use the native .copy from powerpoint then I can use the getdata from the dll without any problem. However, the setdata on shapes doesn't put anything in the clipboard and the error message is "wrong format". So if I can't use it to copy shapes to the clipboard, what type of objects can I copy with setdata???
    Thank you.

  6. #6
    New Member
    Join Date
    Nov 2012
    Posts
    1

    Re: clipboard activex for vba, vbs etc

    Hi, this looks exactly like what i need, can you tell me how to register the dll and where to save it? many thanks in advance
    David

    Quote Originally Posted by westconn1 View Post
    i am posting an activex dll to simplify the clipboard usage for vba or any script language without clipboard object

    hope it may be useful to someone

    usage add a reference or createobject("clipbrd.clipboard")
    has same methods as vb6 clipboard object

    .settext text : returns boolean, true on success
    .gettext : returns string
    .clear : returns boolean
    .setdata object, format : format is optional clipboard format, returns boolean
    .getdata(format) : returns object
    format parameter is optional and should be a clipboard constant value

    Note the constants i copied from msdn may not all be correct, or are outdated, see
    http://msdn.microsoft.com/en-us/library/ebwdx8yh.aspx


    sample
    vb Code:
    1. Set myclip = CreateObject("clipbrd.clipboard")
    2. SavePicture myclip.GetData(2), "C:\test\clippic.bmp"

    to use unzip and register

    vb6 source available if anyone wants

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    can you tell me how to register the dll
    regsvr32 fullpath\clipboard.dll
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    New Member
    Join Date
    Apr 2013
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    Quote Originally Posted by westconn1 View Post
    regsvr32 fullpath\clipboard.dll
    Hello, I am sorry to revive this dead thread, but I have used this DLL file on my application.. It works amazing on a 32-bit environment.. However some of my users are using a 64 bit version, in which I keep getting the error..
    Error 429 : ActiveX Component can't create object.
    I tried the following,

    VB Code:
    1. Public Sub SaveClip2Bit(savePath As String)
    2. On Error GoTo errHandler
    3.     Dim myClip As clipbrd.clipboard
    4.     'Dim myClip As Object
    5.     Set myClip = New clipbrd.clipboard
    6.     'Set myClip = CreateObject("clipbrd.clipboard")
    7.     AltPrintScreen
    8.     'Where AltPrintScreen is a Custom function to capture the active screen..
    9.     SavePicture myClip.getData(vbCFBitmap), savePath
    10. exitOnErr:
    11.     Exit Sub
    12. errHandler:
    13.     Resume exitOnErr
    14. End Sub
    but no avail.. So I just wanted to know is there a 64 bit equivalent of the same? If not can I please see the VBA code?

    Just to add more info, I have Registered the DLL (using Admin mode) under the C:/Windows/SysWOW64.. I have tried it several times.. I just cannot overcome this error.. Am I doing something wrong? I hope not, as it works great on 32-bit. Would appreciate any help.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    i will look into it shortly
    i have only recently got w7 x64, so could not try out before
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10
    New Member
    Join Date
    Apr 2013
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    Thank you so much.. I really appreciate it.. Most of the code I found does not seem to work on the 64-bit environment.. A real pain with two different versions..

  11. #11
    Registered User
    Join Date
    Apr 2013
    Posts
    1

    Thumbs up Re: need source code

    Hi can you please provide the source code as my company policy will not allow me to use this library directly.Thanks

  12. #12
    New Member
    Join Date
    Apr 2013
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    Hello Pete, I forgot to post my solution.. After much trial, I finally managed to crack it.. However I did not use the 'Clipboard.DLL'.. I had to create my own code, by using various resources found online I was able to achieve this..

    @mk8019 : If you would like to see the solution, please refer to the thread located at Access World Forums - Print Screen Into Image File, where I have placed a working demo to help you understand..

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    sorry i did not get back to you, i intended to find the source code, but so far have not looked for it at all

    glad you managed to find some solution
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  14. #14
    New Member
    Join Date
    Apr 2013
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    That's okay Pete, but if you do find the code I would be happy to look at it.. Having a library function will look more neat.. Would appreciate if you could..

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    having finally got around to testing, i found that this dll works fine on w7 64 bit, as long as it is registered correctly
    must be done from an elevated command prompt, otherwise registration fails with error
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  16. #16
    New Member
    Join Date
    Apr 2013
    Posts
    5

    Re: clipboard activex for vba, vbs etc

    Is there any instruction on how to register using an elevated command prompt?

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    run msdos prompt, by right click > run as administrator
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  18. #18
    New Member
    Join Date
    Dec 2019
    Posts
    3

    Re: clipboard activex for vba, vbs etc

    Hello!
    How can i save image from clipboard in vbscript (there's no SavePicture)?
    There I can save only binary data with ADODB.Stream/SAPI.SpFileStream.

  19. #19
    New Member
    Join Date
    Dec 2019
    Posts
    3

    Re: clipboard activex for vba, vbs etc

    westconn1, сould you add a save function to your component?
    Otherwise, work in the claimed vbs remains incompleted.

  20. #20

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    sorry for the delay response, i did not see the new post, not that i was ignoring

    saving pictures to disk was out side of the scope for this project

    on searching i found an alternative using a freeware cmdline program, but i have not tested it
    http://tips-testing.blogspot.com/200...-as-image.html

    it links to the freeware at
    https://www.irfanview.com/

    it will allow to save directly to .jpg, so no need to convert from .bmp, which i was previously doing from vb6
    i might be looking at this for my own use too
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  21. #21

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: clipboard activex for vba, vbs etc

    sorry for the delay response, i did not see the new post, not that i was ignoring

    saving pictures to disk was out side of the scope for this project

    on searching i found an alternative using a freeware cmdline program, but i have not tested it
    http://tips-testing.blogspot.com/200...-as-image.html

    it links to the freeware at
    https://www.irfanview.com/

    it will allow to save directly to .jpg, so no need to convert from .bmp, which i was previously doing from vb6
    i might be looking at this for my own use too
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  22. #22
    New Member
    Join Date
    Dec 2019
    Posts
    3

    Re: clipboard activex for vba, vbs etc

    westconn1
    Thanks for the answer, but I wasn't interested in any image creation tools. I have been using IrfanView for more than 20 years and I know what it is capable of. The same goes for NirCmd. I want to be able to do this in the framework of the VBScript language and miniature ActiveX-components, which I connect with manifests without registration. And it is very sad that SavePicture is missing there. So I ask you to embed the function in the component so to be able to save an image from the clipboard in the context of GetData. If you will make an additional library where both possibilities will be present, I will be very grateful.

  23. #23
    New Member
    Join Date
    Oct 2021
    Posts
    1

    Re: clipboard activex for vba, vbs etc

    I am attempting to use this dll with Excel. I have managed to register is with Windows and have referenced it within my vba project. But when I try to call it within the project I receive an error "Class Not Registered" when using the example code Set myClip = CreateObject("clipbrd.clipboard"). I am probably a bit over my head here but somehow I think I need to declare something in Class Module but not sure what.

    Any help would be appreciated as this provides some functionality that I cannot find natively in Excel VBA at the moment when trying to save images from a worksheet.

Posting Permissions

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



Click Here to Expand Forum to Full Width