Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-03-2014, 05:31 PM
Deltaj Deltaj is offline addpicture coordinates keep me in the first page Windows 7 64bit addpicture coordinates keep me in the first page Office 2013
Novice
addpicture coordinates keep me in the first page
 
Join Date: Nov 2014
Posts: 5
Deltaj is on a distinguished road
Default addpicture coordinates keep me in the first page

I am working on a A6 card landscape layout and all the code is working fine to create the first page. After the final paragraph, I used this code (I copied it from a help page) to force a page break and start the next page:

With ActiveDocument.Paragraphs(6).Range
.Collapse direction:=wdCollapseEnd
.InsertBreak Type:=wdPageBreak
End With



The code then repeats to enter the same text again (ultimately each page text will differ, but for debugging I'm using the same code with incremented paragraph numbers. The text goes in as expected on the second page but a logo inserted with this code does not:

ActiveDocument.Shapes.AddPicture FileName:= _
"C:\somefilename.bmp", LinkToFile:=False, _
SaveWithDocument:=True, Left:=300, Top:=1, Width:=100, Height:=100

The logo over-prints the existing logo on the first page, not on the second page as required. How do I tell vba to measure the coordinates from the top of the second (and subsequent) pages?

I also have code to put in textboxes with similar type coordinates and I suspect these will have the same problem. Eventually I plan to put the code in a loop, read from a txt file for data, and repeat many times to print out a lot of A6 size cards.
Thank you for any help.

Last edited by Deltaj; 12-03-2014 at 05:41 PM. Reason: incorrect title should be "addpicture"
Reply With Quote
  #2  
Old 12-03-2014, 08:42 PM
macropod's Avatar
macropod macropod is offline addpicture coordinates keep me in the first page Windows 7 64bit addpicture coordinates keep me in the first page Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Dim Rng As Range
With ActiveDocument
  Set Rng = .Range
  With Rng
    .Collapse direction:=wdCollapseEnd
    .InsertBreak Type:=wdPageBreak
    .Collapse direction:=wdCollapseEnd
  End With
  .Shapes.AddPicture LinkToFile:=False, Anchor:=Rng, _
    FileName:="C:\somefilename.bmp",  _
    SaveWithDocument:=True, Left:=300, Top:=1, Width:=100, Height:=100
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-04-2014, 02:13 PM
Deltaj Deltaj is offline addpicture coordinates keep me in the first page Windows 7 64bit addpicture coordinates keep me in the first page Office 2013
Novice
addpicture coordinates keep me in the first page
 
Join Date: Nov 2014
Posts: 5
Deltaj is on a distinguished road
Default Solved

Thanks again. As I expected the problem persists with textboxes but that is another thread....
Reply With Quote
Reply

Tags
addpicture, coordinates, pagebreak



Similar Threads
Thread Thread Starter Forum Replies Last Post
addpicture coordinates keep me in the first page Calculate the coordinates of a DocVariable, Bookmark or paragraph. MaxInCO Word VBA 5 12-11-2013 03:28 PM
Page layout: skipping one page for new elements added at end of a page MarcA Word 3 09-30-2013 02:58 PM
2 page document printing problem, text from page 1 in layout of page 2 when printed laurawether45 Word 1 08-02-2012 07:03 AM
addpicture coordinates keep me in the first page x,y,z coordinates with single space "need tab" gsrikanth Excel 1 07-07-2012 08:16 AM
addpicture coordinates keep me in the first page MS Word, page goes to next page when entering data on previous page munna94 Word 2 12-30-2010 08:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft