#1
|
||||
|
||||
Insert graphic file and position at top left corner of page
Hi
Hopefully this is a straightforward request, but getting it exactly right has had be scratching me head a bit. I want to insert an image file into a document, positioned at top left (ie 0,0 from the page) and resize it to the whole page, then set it's wrapping to behind and set it so it does not move with text. I have this cobbled together so far: Code:
Sub testaddshape() Dim myshape As Shape Set myshape = ActiveDocument.Shapes.AddPicture(FileName:="c:\test\overlay.png", _ LinkToFile:=False, _ SaveWithDocument:=True, _ Left:=-ActiveDocument.PageSetup.LeftMargin, _ Top:=0, _ Width:=ActiveDocument.PageSetup.PageWidth, _ Height:=ActiveDocument.PageSetup.PageHeight) With myshape .ZOrder msoSendBehindText .WrapFormat.Type = wdWrapBehind .LockAnchor = True .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage .RelativeVerticalPosition = wdRelativeVerticalPositionPage End With End Sub Currently when I run the code, I can get the size right, set to 'behind' wrapping, and position to the left correctly. What I can't do is set the height so it's right at the top of the page. Currently I get this: Hopefully you can see the top of the graphic will not go any higher than my top margin. Can anyone help me just finish this off so it goes right to the top? I've seen another post on the forum here: https://www.msofficeforums.com/word-...0-vba-tip.html ... where the graphic is positioned in the header - I could not seem to adapt this to my needs and I'd rather it stay on the page if possible anyway. Thanks in advance for any help. |
#2
|
||||
|
||||
Try this one
Code:
Sub testaddshape() Dim myshape As Shape Set myshape = ActiveDocument.Shapes.AddPicture(FileName:="c:\test\overlay.png", _ LinkToFile:=False, _ SaveWithDocument:=True, _ Left:=0, _ Top:=0, _ Width:=ActiveDocument.Sections(1).PageSetup.PageWidth, _ Height:=ActiveDocument.Sections(1).PageSetup.PageHeight) With myshape .ZOrder msoSendBehindText .WrapFormat.Type = wdWrapBehind .LockAnchor = True .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage .RelativeVerticalPosition = wdRelativeVerticalPositionPage .Left = 0 .Top = 0 End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
Perfect!
Thanks for taking time to reply to this, it's really appreciated! |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word Doc printing tiny in left top corner margin | waynefusion | Word | 6 | 11-02-2016 08:59 AM |
insert .pdf (scanned file) as graphic | eNGiNe | Word | 3 | 09-30-2015 11:40 PM |
Circle visible in top left corner when saving page with a 'flow-text box as PDF | Clover_Creative | Word | 0 | 05-30-2014 05:03 AM |
Positioning Footer Graphic to Butt the Left Edge of the Page EXACTLY | WLK | Drawing and Graphics | 3 | 09-26-2012 08:53 PM |
Delete upper left corner of picture | tom_94305 | Word | 1 | 08-03-2012 09:09 PM |