+ Reply to Thread
Results 1 to 5 of 5

Macro to auto-import images, resize them, and fit them to specific locations on the page

  1. #1
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Macro to auto-import images, resize them, and fit them to specific locations on the page

    I don't even know if this is possible, but I wanted to ask.

    I am trying to create a template document that, when a macro is activated, a specific number of images from a designated folder are imported into the document, resized to specific dimensions, and placed at specific coordinates on the page. The name of the image governs how they are imported into the document. For example, an image named "1" will be imported, resized, and relocated to a specific spot, an image named "2" will be imported, resized, and relocated to a specific spot, and so forth.

    Ideally, I wanted to do this in Word, but the stricter layout rules that govern Word's interface makes me think this will be much more achievable in Excel.

    Is this possible, and, if so, what would be the best way to go about it? I've been mainly researching how to do this in Word, and haven't been able to find any solutions that fit what I'm looking to do.

  2. #2
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Macro to auto-import images, resize them, and fit them to specific locations on the pa

    The VBA code below from Excel will print a couple of lines of text with a moveable picture on each page. Note that Word "SUCKS" when it comes to printing with VBA as the position of the cursor is not always obvious.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Macro to auto-import images, resize them, and fit them to specific locations on the pa

    Hi EssoExplJoe - thanks for this. I have a few questions, because I am by no means an expert in VBA:

    - Is this macro for Word or Excel? In your response you mention Excel, but the first comment in the code mentions "Word Document".

    - Does this go in its own module, or in the ThisDocument object (if Word) or ThisWorkbook object (if Excel)?

    - I don't need to add any text with this macro. Just images. And they each need to be resized/positioned differently. Image "1" will have a different size and position than image "2". Not only that, but these images will not be placed one after another with a blank line separating them. They have very specific, static locations on the page that ignore the traditional structure of the document. For example, most of the images are to be inserted in a table within the document. I may be reading it wrong, but the code you provided doesn't seem to address this kind of sizing/positioning. Am I reading it wrong?

  4. #4
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Macro to auto-import images, resize them, and fit them to specific locations on the pa

    This is an Excel Macro that prints from Excel to a Word Document. The aShape is resized by the .width and .height setting to whatever size you want. As far as putting the image into a word table, I haven't done that but suspect it will require a lot of trial and error. I spend several days to get this macro to put images on Word Pages. I think it might be simpler to write a macro that runs within a word document but haven't done that.

  5. #5
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Macro to auto-import images, resize them, and fit them to specific locations on the pa

    I was able to get this macro working in Excel using this VBA code, but I really need to do this in Word, not Excel. Here is some example code from my Excel macro, working with four images:

    Please Login or Register  to view this content.
    I achieved this in Excel by turning on the "Record Macro" feature and, one at a time, importing all images from a specific cell location (so they would always adjust/move from the same location each time), resizing them from that location, then moving them to the appropriate spots with my arrow keys so I could calculate the exact IncrementLeft and IncrementTop coordinates for each image.

    However, as I said above, I really need to do this with a Word macro, not Excel. I've been researching how to do this in Word, but am surprised that I haven't come across any solutions yet. The fact that Word disables the ability to import images when in "Record Macro" mode has been a huge roadblock for me, since I am not great at writing VBA freehand. Unfortunately, I don't think this same approach that I used with this Excel macro will work for Word, given the more rigid nature of a Word document relative to using images. All of the images need to be inserted into a table within my Word document.

    Any help would be very much appreciated!
    Last edited by hysterical.useless; 01-26-2018 at 04:58 PM.

+ 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. Macro to autom. display images from URL, resize picture and move and size with cell
    By AshtonMcFish in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2013, 06:38 AM
  2. macro to resize multiple images
    By Blake 7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2012, 12:14 PM
  3. Macro to import and resize images to cell
    By wilsonyeoh in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2011, 01:58 AM
  4. Macro import images
    By meccer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2010, 09:21 AM
  5. Excel Macro Import web image, crop, and resize.
    By jdax57 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2009, 08:30 AM
  6. Import images from web page
    By jenn13 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-22-2008, 11:31 AM
  7. Relative import locations in macro
    By rbmcclen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2006, 08:13 AM
  8. Import And Resize Images
    By 2eXtreme in forum Excel General
    Replies: 6
    Last Post: 02-05-2006, 12:00 PM

Tags for this Thread

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