+ Reply to Thread
Results 1 to 14 of 14

Replacing Logo images across workbook from a specified file location

  1. #1
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Replacing Logo images across workbook from a specified file location

    Hello Everyone!

    I have a question that I'm not sure is possible to achieve.

    I have a Dashboard Workbook with the following 10 sheets (by name):

    • Dashboard
    • Measure Definitions
    • Data Entry
    • Action Plan
    • Reporting
    • 1
    • 2
    • 3
    • 4
    • Update

    Every one of these sheets has the same logo on it. It's dimensions (if that is important) is a height of 1.25 inches and a width of 2.14 inches.

    Is there a way to set up a macro whereby all the logos can be changed at once to another logo/image?

    This dashboard will likely be used by personnel from several different companies/agencies, and I want to see if I can make swapping out the logo easy, rather than them having to manually do it 10 or more times (there are two of the same logo on the Reporting tab, one next to the navigation buttons and one in the print-able area). Even if it can only be achieved with the 10 in the navigation menu, that's more than fine with me.

    Is it possible to replace all images without affecting charts or inserted shapes that are on each sheet?

    If it is possible, I'd like to arrange it so they can put a file named "logo" in a folder named "PM Dashboard." When you press the associated button, it uses this file location to insert that image in place of all the others. I would put this button on the "Update" worksheet if that is relevant to the VBA code.

    If this is not possible, I guess they will simply be out of luck as far as getting the easy way out of logo replacement.

    Thanks in advance!

    -LM

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Replacing Logo images across workbook from a specified file location

    The below code cycles through each shape in each worksheet.
    If the shape is named "LogoPic" it is deleted and replaced with the image located at:
    C:\_RonResources\Pictures\LogoPic.jpg

    Change that location and the name of your logo image to match your situation

    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    Hi Ron!!!

    First I want to thank you for taking the time to detail this code. I apologize I could not get back to you sooner (other business matters took precedence and I could not even attempt to implement the code until now).

    When I ran the code, I did not get any errors (which is good!). But also nothing else happened. The "Done" popup was all that happened after running the macro.

    I used your code with the following difference: C:\Users\********\Desktop\PM Dashboard\Logo\LogoPic.jpg The asterisks are not actually in the link, I only blurred out my last name (no spaces).

    When I run the macro, the dialog box with "done" appears almost immediately but otherwise nothing else (that I can see) has changed.

    Any thoughts on possible corrections (if the whole venture is possible that is)?

    I have one final question: I expect the directory of this folder to change. All the dashboard worksheets are located in a folder called PM Dashboard. But this folder as a whole will be distributed and, in some cases, be on a different letter drive. Is there a ambiguous way to refer to the file-path such that it looks at the PM Dashboard Folder and then the Logos sub-folder only?

    Thanks so much for your time!

    -Brandon

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Replacing Logo images across workbook from a specified file location

    If the image did not actually change, you wouldn't notice any difference.

    But if it did...
    - Are all of the logo images in each worksheet named LogoPic?
    - Did you try to step through the running code to see what it's finding?

  5. #5
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    Okay!

    So Here is what I've managed to achieve:

    1. I learned how to make sure the name of the logo picture in excel matched what your macro called for (that was my initial problem, you had it right).

    2. I put a very different picture in the target folder to verify that the logo actually changed. The picture is changing, but its not holding the same dimensions as the original (This is a big goal of mine. If it ends up that the end user has to resize the pics, it would be easier not to use the macro : p).

    The dimensions of the pictures in excel now-according to excel and with the exception of one picture that is smaller- are at a height of 1.25 inches and a width of 2.14 inches.

    When I run the Macro, the picture that is replaced comes in with dimensions: height of .28 inches and width of .27 inches.

    I took off the "Comment" quotes as you suggested but this has not affected the outcome of picture size.

    Is there a way to ensure the new logo enters in with the dimensions above?

    3. Do you know if the file path can be made flexible? What I mean by this, is that if I zip the folder containing the complete dashboard system, and someone opens it on their computer, will that break this macro's function because its looking for file path referring to my desktop? Is there a way to refer to the folder called "Logo" that is then in in the parent folder "PM Dashboard"?

    It's almost where I'd like it and you've been an incredible help! Thanks for taking the time!

    -LM

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Replacing Logo images across workbook from a specified file location

    OK...This edited code records the size of the image being replaced and uses those dimensions on the new LogoPic.

    Please Login or Register  to view this content.
    As far as the location is concerned...
    I'd recommend using a network location AND referencing it with the UNC (Universal Naming Convention) instead of a mapped drive.
    Example:
    Please Login or Register  to view this content.
    Next best would be putting the picture in the same exact location on each PC:
    Please Login or Register  to view this content.
    Last, you could reference the user's desktop this way:
    Please Login or Register  to view this content.
    Does that help?

  7. #7
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    Ron, Wow! You are awesome!

    I had another minor issue but managed to fix it myself!

    That issue was that every time I ran the macro the image would present properly, but be placed one column to the right.

    When I noticed your column offset code I simply changed the 1 to 0 and everything is working smoothly. I used your last reference option and that also works great (I figure I can tell them the folder needs to be on the desktop when they "press the button" in order to update the images. Then it can be moved anywhere)!

    I can't thank you enough!

    -LM

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Replacing Logo images across workbook from a specified file location

    Glad you got something you can use!

    If that resolves your issue, please take a moment to mark this thread as SOLVED (from the Thread Tools menu)

  9. #9
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    Hi Ron,

    I marked the thread solved but I have one quick follow-up.

    Occasionally when the macro is run a few times, the images still move a row or a column in various directions. Is there a way I can specify in the code that I want cell B5 in every sheet to be the top left location the new logo is pasted into?

    Thanks,

    -LM

  10. #10
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    I changed the thread back to unsolved just in case members are no longer notified of new responses under the Solved status.

  11. #11
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Replacing Logo images across workbook from a specified file location

    Try this (untested):
    Please Login or Register  to view this content.
    Does that help?

  12. #12
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    Works like a dream Ron. Fantastic!

    Thank you so much,

    -LM

  13. #13
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    Hi Ron,

    Recently I came across a problem where this code started to break.

    Please Login or Register  to view this content.
    The debugger says the problem is here:

    Please Login or Register  to view this content.
    Where the Delete line was the highlighted problem spot. The error code was: "Run-Time Error '-2147024809 (80070057)': The specified value is out of range."

    I copied in your original code to see if it was something I broke after the fact and the debugger said the problem then lied in this area:

    Please Login or Register  to view this content.
    Personally I'm a little baffled why it suddenly is choosing not to work.

    If you happen to see this or someone else can shed some light that would be awesome!

    However I have one difference I'd love to work into the code.

    Rather than requiring the folder to be on the Desktop, I've come across this code I used in another Macro to work backwards on the filepath.

    Please Login or Register  to view this content.
    Where "Test Folder" was my destination before. Now, my destination is the Logo folder and the Logopic.jpeg we arranged before. I'm not sure if it will work with the code you originally helped with, but I thought I'd see if it could be incorporated because it will remove a burden.

    Thanks in advance!
    Last edited by liquidmettle; 04-20-2015 at 08:33 AM.

  14. #14
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Replacing Logo images across workbook from a specified file location

    I have decided to go with a different solution to this problem but I still would love to understand why the code has broken in this instance.

+ 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. Column chart - logo's/images in Category axis
    By Jabba69 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-21-2014, 04:40 PM
  2. Copy, edit and save workbook to same location as source data file, not macro file.
    By Jasonhouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 09:01 AM
  3. [SOLVED] Specify export pdf file location is location workbook is saved.
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2014, 01:13 PM
  4. Call a specific workbook from a file location and move worksheet to different workbook
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2014, 01:46 AM
  5. Replies: 2
    Last Post: 06-18-2013, 12:15 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