+ Reply to Thread
Results 1 to 5 of 5

Formatting header picture dimensions

  1. #1
    Registered User
    Join Date
    06-05-2017
    Location
    London, UK
    MS-Off Ver
    2010
    Posts
    3

    Formatting header picture dimensions

    Hi All,

    I am new to the forum and to VBA. Below is an extract of code I have written which aims to format the margins and headers based upon the version of excel the template is opened in. It works perfectly except for the formatting of the existing center header picture. Please advise

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formatting header picture dimensions

    You did not explain whether the problem is with Excel2007 or Excel2010 or both.
    And you did not explain what it is doing wrong. Is it placement, size, ... etc?

    Instead of accepting the current image, delete it, and instead add it in via VBA and see if that solves the problem
    - this is the VBA that you need to add (amend the file path to your image )
    Please Login or Register  to view this content.
    Tested with Excel2010 (do not have 2007 on my machine)

    Incidentally your code will be ignored if anyone is running anything after 2010.
    You could amend:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.
    Last edited by kev_; 06-06-2017 at 04:42 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    06-05-2017
    Location
    London, UK
    MS-Off Ver
    2010
    Posts
    3

    Re: Formatting header picture dimensions

    Thanks Kev,

    The issue is that I get a Runtime Error 1004 when I run the code. I had considered this but am concerned that someone may delete the image or the file path could change. Is there any way to edit the existing image?
    I've not tried it in 2007 yet, but I'm hoping it will run. Thanks for pointing out the version issue- I've ammended that now!

    Thanks again,
    Andrew.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Formatting header picture dimensions

    I replicated Runtime Error 1004 when I deleted &[Picture] from the Center Section Header - so that is probably a big clue

    How did you insert the picture originally? Like this perhaps?
    InsertPicture.jpg


    If you insert this into your code (within With ws.PageSetup) what does it return?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-05-2017
    Location
    London, UK
    MS-Off Ver
    2010
    Posts
    3

    Re: Formatting header picture dimensions

    Yes, I inserted the image in the page setup tab as you've shown. Do I have to insert a new image each time? When I enter that line the message box says the file name of the existing image.

    Many Thanks,
    Andrew.

+ 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. Insert picture and auto rotate and resize to cell range dimensions
    By jwagman1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2012, 03:49 PM
  2. Cell formatting for Dimensions
    By MattG in forum Excel General
    Replies: 1
    Last Post: 04-06-2010, 01:17 PM
  3. Picture template, keeping same height/width dimensions
    By cmf0106 in forum Excel General
    Replies: 1
    Last Post: 11-19-2009, 12:35 PM
  4. picture in header
    By howardjo in forum Excel General
    Replies: 2
    Last Post: 12-06-2007, 08:19 AM
  5. I can print my Header Picture!! >=(
    By Luisa in forum Excel General
    Replies: 0
    Last Post: 07-18-2006, 09:05 AM
  6. [SOLVED] Picture in header
    By Steve in forum Excel General
    Replies: 2
    Last Post: 06-25-2006, 04:30 PM
  7. Header Picture
    By [email protected] in forum Excel General
    Replies: 10
    Last Post: 08-04-2005, 04:05 PM
  8. [SOLVED] Picture in Header
    By Esrei in forum Excel General
    Replies: 2
    Last Post: 06-03-2005, 11:05 AM

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