How to Copy Image or Picture to Clipboard in VB 6 Programming?

Saturday, July 11, 2009 ·

In many VB program applications display images. And maybe you want to copy the image and paste into other office program like MS Excel, MS Word, etc. To do this thing in VB6 programming, please follow below steps of simple VB programming tips:
First, you should have a picture that will be loaded by the program. For example you have a picture or image file named Adenium.jpg, and you save your picture in a folder with name D:\MyPicture

  • Open your Microsoft VB6 program
  • Create a VB project for example Project1
  • Create a standard form for example Form1
  • Create an image object from the toolbox for example Image1
  • Create a command button for example Command1
    Please look at below screen shot for your illustration.

    How to Copy Image to Clipboard VB Program
  • Double click any where in Form1 area to create a Sub Form_Load()
  • And then type below program coding in the Sub Form_Load() area

    'Load picture into image box
    Image1.Picture = LoadPicture("D:\MyPicture\Adenium.JPG")


  • Double_click Command1 button to create a Sub Command1_Click()
  • Write down below program coding in Sub Command1_Click() area

    'Clear clipboard first
    Clipboard.Clear
    'Load the picture from Image1 into Clipboard
    Clipboard.SetData Image1.Picture


  • So your program will look like the following list:

    Private Sub Command1_Click()
    'Clear clipboard first
    Clipboard.Clear
    'Load the picture from Image1 into Clipboard
    Clipboard.SetData Image1.Picture
    End Sub
    Private Sub Form_Load()
    'Load picture into image box
    Image1.Picture = LoadPicture("D:\MyPicture\Adenium.JPG")
    End Sub


    Please look at below screen shot for your illustration.
    How to Copy Image to Clipboard VB program



    To check whether your program works or not:

  • Click Start panel on your VB design screen
    If your Image appears on your screen it means that your Sub Form_Load() is working.
    How to Copy Image to Clipboard VB Program


  • Click Command1 command button to copy your image into clipboard
  • Open an Office Program like MS Excel
  • Place your pointer in one of MS Excel cell (for example place in cell A1)
  • Right_Click, then click Paste
    If your picture appears on your MS Excel sheet it means that your program is working properly.

  • How to Copy Image to Clipboard VB Program

    How to Copy Image to Clipboard VB Program

    It's just a very easy thing to do, isn't it?


    2 comments:

    Bali Info said...
    July 17, 2009 at 8:46 AM  

    It's so easy to copy image into clipboard.

    image clipping said...
    October 31, 2009 at 10:44 AM  

    Great stuff! Thanks!!

    Regards,
    clipping path

    Post a Comment