Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-20-2017, 05:31 AM
stewarto stewarto is offline inserting an image at current position Windows 10 inserting an image at current position Office 2016
Novice
inserting an image at current position
 
Join Date: Mar 2017
Location: Haarlem, Netherlands
Posts: 4
stewarto is on a distinguished road
Question inserting an image at current position

I have a macro which inserts an image at the current position but since a short while it inserts at the top of the page!

Can anyone help?

myperson = "john_doe"
myfile = "g:\office\files\" + myperson + ".bmp"


ActiveDocument.Shapes.AddPicture(Anchor:=Selection .Range, FileName:=myfile, _
LinkToFile:=False, SaveWithDocument:=True).WrapFormat.Type = wdWrapSquare
Reply With Quote
  #2  
Old 03-20-2017, 07:16 AM
dwirony dwirony is offline inserting an image at current position Windows 7 64bit inserting an image at current position Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 49
dwirony will become famous soon enough
Default

Try this instead:

Code:
Sub InsertPicture()
myperson = "john_doe"
myfile = "g:\office\files\" + myperson + ".bmp"
Selection.InlineShapes.AddPicture FileName:= _
        myfile, LinkToFile:=False, _
        SaveWithDocument:=True

End Sub
Although this may lose your wrap format. Is that something you need?
Reply With Quote
  #3  
Old 03-20-2017, 07:39 AM
stewarto stewarto is offline inserting an image at current position Windows 10 inserting an image at current position Office 2016
Novice
inserting an image at current position
 
Join Date: Mar 2017
Location: Haarlem, Netherlands
Posts: 4
stewarto is on a distinguished road
Default

Thanks for your help, dwirony, but I get the following error (translated from the original Dutch)

error -2147467259 (80004005)
Method AddPicture of object InlineShapes failed
Reply With Quote
  #4  
Old 03-20-2017, 07:53 AM
dwirony dwirony is offline inserting an image at current position Windows 7 64bit inserting an image at current position Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 49
dwirony will become famous soon enough
Default

Strange - It's working fine on my computer. Are you sure you have the right filepath?
Reply With Quote
  #5  
Old 03-20-2017, 08:02 AM
stewarto stewarto is offline inserting an image at current position Windows 10 inserting an image at current position Office 2016
Novice
inserting an image at current position
 
Join Date: Mar 2017
Location: Haarlem, Netherlands
Posts: 4
stewarto is on a distinguished road
Default

Yes. The filepath works with my macro, but it puts the image at the top of the page
Reply With Quote
  #6  
Old 03-20-2017, 09:29 AM
dwirony dwirony is offline inserting an image at current position Windows 7 64bit inserting an image at current position Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 49
dwirony will become famous soon enough
Default

So it was working fine before but now it is not? Is it because there is a space between "Selection" and ".Range"?

Code:
Anchor:=Selection .Range
Can you try removing that space?
Reply With Quote
  #7  
Old 03-21-2017, 02:40 AM
stewarto stewarto is offline inserting an image at current position Windows 10 inserting an image at current position Office 2016
Novice
inserting an image at current position
 
Join Date: Mar 2017
Location: Haarlem, Netherlands
Posts: 4
stewarto is on a distinguished road
Default

Sorry, it was FFS (fat finger syndrome).

The space does not exist in the real macro.
Reply With Quote
  #8  
Old 03-21-2017, 02:37 PM
dwirony dwirony is offline inserting an image at current position Windows 7 64bit inserting an image at current position Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 49
dwirony will become famous soon enough
Default

I'm afraid that with my limited knowledge I cannot help you...

Hopefully someone like gmaxey or macropod will come along and solve your mystery
Reply With Quote
Reply

Tags
word vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to position an image at a specific location from the edge of the screen / paper? SpeedD PowerPoint 1 01-28-2015 08:04 AM
Losing image resolution when inserting image into MS word (2011: Mac) Mario.N Drawing and Graphics 0 11-23-2014 02:38 AM
Problem Inserting Image rbonnell PowerPoint 1 07-22-2014 07:15 AM
inserting an image at current position Word 2010 how do i set default position for image sam2149 Word 2 03-29-2014 01:41 AM
inserting an image at current position Macro for moving one cell down from current position Johnny thunder Word VBA 3 04-07-2011 04:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:31 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