Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2012, 07:11 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting Image to each page in word 2007

Dear All,

I wrote a small VBA routine to insert an image to each page of a word document, and it worked fine on Word 2010. But when I tested that with word 2007, it advances page by page, but inserts the image to the first page, instead of inserting on the next page.

Here is the code:

For i = CurPage To CurPage + NumOfPages - 1
Set WORD_Image = Word.ActiveDocument.Shapes.AddPicture(ImageName, , True, 0, 0, 10, 10)
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1
Next


Would you please show me how to make it work on 2007?

thanks

massoud
Reply With Quote
  #2 (permalink)  
Old March 18th, 2013, 12:59 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Unable to replicate it.. there are chances that the Selection is within a TextBox or Image which is not allowing the next command..

Try using Selection.Collapse to come out of the selection and proceed

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
  #3 (permalink)  
Old March 18th, 2013, 02:04 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting Image to each page in word 2007

Thanks for the reply.
I posted that case one year ago, and asa far as I remember I could make it work by changing the code to:
Set WORD_Image = .InlineShapes.AddPicture(FileName:=ImageName, SaveWithDocument:=True, Range:=Rng).ConvertToShape

Thanks
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2007 shortcut to open the UserForm cjcant Word VBA 1 June 6th, 2011 06:46 AM
XSLT Problem with Word 2007 Half-Saint XSLT 1 January 6th, 2010 07:49 AM
Word 2007 VBA validation of formfield beth.harless Word VBA 0 August 18th, 2009 02:24 PM
Word 2007, undo, VBA FredrikH Word VBA 0 April 16th, 2009 04:20 AM
Inserting an image in the header of a word documen Michael109 Access 3 April 4th, 2007 11:26 AM



All times are GMT -4. The time now is 01:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.