+ Reply to Thread
Results 1 to 7 of 7

How to apply Image borders to an image that my excel vba userform pastes in a word doc?

  1. #1
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    24

    How to apply Image borders to an image that my excel vba userform pastes in a word doc?

    My User form captures the screen print of the window and pastes it in a word document. But I wanted to apply a thick border of color red/black to the image as soon as I paste the image. After googling I found that we can use InlineShapes in VBA to apply picture borders and tried the below code, but this throws me an error 'Variable not found'.

    Can anyone help to get this sorted out?

    Code:

    sub captureAndPasteWindow()

    keybd_event VK_SNAPSHOT, 0, 0, 0

    WordObj.Selection.Paste

    WordObj.Selection.InlineShapes(1).Select

    With Selection.InlineShapes(1)
    .Line.BackColor = vbBlack
    .Line.Weight = 20
    .Line.Style = msoLineSingle
    End With

    End Sub

    - Captain Cool

  2. #2
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: How to apply Image borders to an image that my excel vba userform pastes in a word doc

    Is that your full original code? Can you share the workbook or original code so we can update it?

    You should be able to simply record a macro do what you want and then take part of the macro you need and add it after the copy/paste portion of your code.
    Last edited by playaller; 05-09-2014 at 03:47 PM.


    Shelton A.
    If Helpful, Add Reputaion!

  3. #3
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: How to apply Image borders to an image that my excel vba userform pastes in a word doc

    Here you go:

    Create a new module within the Project and place this code there. Don't place it in Normal or Template.


    Please Login or Register  to view this content.
    Last edited by playaller; 05-09-2014 at 10:46 PM.

  4. #4
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: How to apply Image borders to an image that my excel vba userform pastes in a word doc

    Thanks a lot Playaller. I'll definitely try this and let you know the result.

    - Captain Cool

  5. #5
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: How to apply Image borders to an image that my excel vba userform pastes in a word doc

    Thanks! But the above solution is not working.

    I tried myself and now I'm able apply borders to the image that my userform pastes in word doc, but it gets applied to all the images as a single border as shown in the attachments. Instead I wanted borders to be applied for each image separately.

    Code that I'm currently using is:

    Please Login or Register  to view this content.
    Problem as follows -
    a. Paste the image >> Success
    b. Apply border >> Success
    c. Any other text typed, pulls/extends the border and the border never ends; All the text and images pasted come under the same border. >> Problem
    I want a separate border for each image.

    Can someone help me to apply border for each image, but not the same border for all the images? Thanks in advance

    - Captain Cool
    Last edited by CaptainCool; 05-11-2014 at 10:26 AM.

  6. #6
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: How to apply Image borders to an image that my excel vba userform pastes in a word doc

    Ha ha !!! I'm very happy! I tried it again and got the issue resolved. I tried the below code and I'm able to apply borders to each of image!

    Please Login or Register  to view this content.
    Special Thanks to Playaller, you gave the idea of using 'Record' option! You deserve a STAR

    - Captain Cool
    Last edited by CaptainCool; 05-11-2014 at 10:28 AM.

  7. #7
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: How to apply Image borders to an image that my excel vba userform pastes in a word doc

    Very nice. Glad too see you got the results you wanted. Even taught me something! Thanks for the rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA to transfer image FROM userform image control TO a worksheet cell
    By Zoediak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 02:51 PM
  2. VBA: Put text from excel to jpeg image by matching image name.
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 01:47 AM
  3. excel 2010 VBA InsertPicInRange only makes shortcut to image instead of copy of image
    By ArjanSpit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2012, 02:57 PM
  4. Copy and Paste Between Workbooks Pastes as Image, not Formula
    By japple in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2009, 08:03 PM
  5. Export UserForm Image for use in Microsoft Word
    By Andy B via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-18-2006, 12:45 PM

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