• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Picture at the top of each Excel page gradually creeps downward, page by page. Why?

BobBridges

Active Member
Here's an odd one: I've written a program for a friend of mine who's living and working in Ireland. (That may be germane; we're not sure.) The program reads a bunch of data from worksheets in the workbook, and creates a report in a separate workbook/worksheet. At every break, the program creates a page break and copies the company logo aligned with the top row of the new page.

When I run the program on my machine, this works fine. When my buddy runs it on his machine, the logo starts out correctly placed but is slightly lower on every page; by the 80th page it's practically a footer. This is evident not just when they print it, but in the report worksheet before printing and in the resulting file when it's exported to .pdf. When an Irish coworker runs the same program, it works fine. So it can't be a bug in the code; there has to be some setting on his machine that's different from mine and his coworkers...doesn't there?

I originally had the .PageSetup using A4 paper, but I switched it to letter size and it still does it. The method of aligning the logo with the top of each page is as follws:
Code:
    ' ows is the worksheet, of course
    ows.Rows(rC).PageBreak = xlPageBreakManual
    Set osh = Logo.Duplicate
    osh.Top = ows.Rows(rC).Top + 2 'distance from the top of the worksheet in points

I suppose it might be a discrepancy between Excel's conversion from inches and centimeters to points, but I don't really believe it, at least partly because I use centimeters myself even though I'm in the US. (Ok, so I'm a geek; so sue me.) Anyone have any ideas?
 
It never occurred to me to ask. I'm using Win 10 and Excel 2010, but should I ask what they're using over there?
 
BobBridges
Why You try to set that logo by VBA? ... Why not use Header with Logo?
I've notice same 'effect', if someone uses other Excel-version than me, especially if 2010.
Values for .Top are different with different versions - for some good reason?
You could test it by let user set own factor. eg if Your logo's .top-value is 100 - factor is 1 and other users can set it eg 0.8 >> it uses value 80.
I don't remember which factor values were useful, but after few tests it's possible to find.
... but why not use Header with Logo?
 
I'm not used to graphics in Excel—don't use them much. So when I tried putting the logo in a cell and then setting a header, and the logo didn't appear on subsequent pages, I just gave up and did it another way.

Wait, maybe I didn't try a header. Now I remember, I tried freezing the top few lines, and that didn't work. The reason I didn't use a header is that all the examples I found dealt with a text header—title, date, page #, etc. I couldn't see how to do it with a picture.
 
BobBridges
Did You try ... this way?
1) add Picture in header
2) adjust top margin
3) have Your data (now, there is some sample data)
4) ... and for me, this works
 

Attachments

  • BobBridges.xlsb
    153.1 KB · Views: 0
Back
Top