+ Reply to Thread
Results 1 to 16 of 16

format a picture with a macro?

  1. #1
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    format a picture with a macro?

    I'm watching an educational D V D on my computer, and take notes in excel. I repeatedly use the print screen command, then go to excel and paste in the picture, though it is too large. I resize it to 50% and I'm done. What kind of code do I need to use to paste and shrink the picture to 50%? Also, how do I attach a shortcut key to this action (for example Ctrl+M)

    Thank you.
    Last edited by l2g; 10-11-2009 at 02:16 PM.

  2. #2
    Forum Contributor vamosj's Avatar
    Join Date
    04-23-2004
    Location
    Oregon
    MS-Off Ver
    2010
    Posts
    294

    re: format a picture with a macro?

    Check out this post by Leith Ross.

    http://www.excelforum.com/947504-post2.html

    Let me know if it needs some more explenation and I'll try and help.

    Since you are using "Print Screen" we can probably just use a value to resize it to instead of 50%
    Last edited by vamosj; 10-11-2009 at 02:30 PM.
    Janos S. Vamos
    Data Systems Technician/Fire Controlman PO1(SW/AW)
    US Navy Retired


    Remember, Record Macro can be your friend for figuring out solutions.

    Good or Bad, let me know how I did by clicking on the "Add Reputation" * just to the lower left of here. it only takes a few seconds to let someone know.

  3. #3
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    re: format a picture with a macro?

    I'm attempting to make the code work... Though how do I attach a shortcut key command to it?

    Thanks

  4. #4
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    re: format a picture with a macro?

    I'm afraid I'm not as skilled enought with VB to make that code work. I just know the very basics....... How do I select the picture to resize? Not sure what to put in place of "expression"

  5. #5
    Forum Contributor vamosj's Avatar
    Join Date
    04-23-2004
    Location
    Oregon
    MS-Off Ver
    2010
    Posts
    294

    re: format a picture with a macro?

    Considering that you are using "Print Screen" to capture parts of your video let's go ahead and introduce you to the Macro Recorder. This little baby helped me to get where I am today in using VBA (as rough as I still am).

    Since each image is going to be coming in the same size (resolution) we can use the macro recorder to record your first resizing operation then we can assign a shortcut key to do the operation for you.

    Follow these instructions and you should be good to go.
    1. Hit Print Screen for any part of your video to capture your first image to work with.
    2. open up your excel document used for your notes.
    3. click where you are going to put this image.
    4. Now on the toolbar where you have file, edit, view, etc..... select Tools - Macro - Record New Macro
    5. Name your macro whatever you want.
    6. Under where you name the macro you should a place you can assign a shortcut key. it'll have ctrl + ___ Just assign a letter, like the letter m you wanted to use.
    7. Hit okay
    8. Now go ahead and paste the picture and resize it to the size you want. (Right click on the picture, select format picture, size).
    9. Once you hit okay to resize it you can now stop your macro recording. Don't select any cell's until after you stop. You can do this by hitting the stop on the floating button that should be hanging around or once again selecting tools, macro, stop recording.
    10. From here you all you'll have to do is hit your print screen, hit the cell you want to paste the image into, then hit ctrl + whatever letter you chose.



    Hopefully this helps you out. Just remember, Macro Recorder can be a great friend to you, but once you start recording it will pretty much capture anything you do, so if you select the cell you are going to paste into after you start the macro recorder, then if you do the macro, it's going to select that cell again.

  6. #6
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    re: format a picture with a macro?

    Thank you for the detailed explanation, though I tried it and it does not work. Excel is not able to record formatting/resizing a picture via a macro recording, unfortunately......

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: format a picture with a macro?

    12G

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    Re: format a picture with a macro?

    Still have not found a solution to this? Does anyone else have any suggestions?

    Thanks

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: format a picture with a macro?

    'm not sure if you can use VBA to capture an image from the D.V.D. I've found this
    Last edited by royUK; 10-18-2009 at 03:55 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: format a picture with a macro?

    Maby the best way of going about it would just be to attach a macro to the ctrl V that will paste the image and go the resize
    Please Login or Register  to view this content.
    you can do a print screen using the keybord event or sendkeys. though if that where the case you would need excel to be the active screen and for you the *** would be the activescreen.

    hope this helps

  11. #11
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    Re: format a picture with a macro?

    The 5-line code above works perfectly! Thank you. I do have one follow up question: How do you attach a shortcut key command (such as Ctrl+V or Ctrl+M) to a sub using strictly VB, and without recording a macro for it via "record macro" command in excel?

  12. #12
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: format a picture with a macro?

    One way is to use the .onkey

    Please Login or Register  to view this content.
    this will run the sub ScreenPaste. When SHift Ctrl K is pressed
    Last edited by D_Rennie; 10-18-2009 at 09:23 AM. Reason: Forgot to say what it does

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: format a picture with a macro?

    Record an empty macro & set the shortcut during the set up

  14. #14
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    Re: format a picture with a macro?

    Had to do a few minor tweaks but got it to work. The macro has to be turned on for it to, work, though.

    Please Login or Register  to view this content.
    Is there any way to do this without first turning the macro on?

  15. #15
    Registered User
    Join Date
    12-01-2008
    Location
    Orlando, FL
    Posts
    8

    Re: format a picture with a macro?

    My last question was to see if the shortcut key commands can be initiated without running a separate macro - see my last post. One of my work books has the following - it is a commad that runs a sub, in this case "GS_C1B", if a value in cell D7 has been changed:

    This code has to be imbedded not in a module but in the actual sheet (under microsoft excel objects in VBA project).

    Is there perhaps something similar to this that can be done to make the short cut keys to run? Just trying to barainstorm to see what other possibilities there are.

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    10-26-2009
    Location
    Charleston, WV
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: format a picture with a macro?

    Thanks for the information
    Last edited by jbowe; 10-27-2009 at 10:01 AM.

+ 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