[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Word 2010 VBA: How to import image and resize height and width with VBA?

Posted on 2013-02-01
2
Medium Priority
?
1,793 Views
Last Modified: 2013-02-02
How do I use VBA to import an image into Word 2010 then rezise the height and width so that the image does not push the other page elements out of place?

Word 2010
Access 2010

Note: the process of creating the Word files runs through a loop in an Access module. Currently, I use Access to copy and replace bookmarked fields in the Word document. However, it is possible that an image may not exist for the document I am creating so I would like that the Word document is still generated even if the image is missing.

Thank you
0
Comment
Question by:CafeTica
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38845386
The image can be added as an inline shape or a 'floating' shape.  An inline shape takes a position as a large character in the text.

The way that text is arranged around a 'floating' shape depends on its wrap setting. Without seeing the document, the only way to be certain that the text is not disturbed is for the shape's wrap setting to be behind or in front of the text.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 38845791
Here is some code to get you started:
Sub AddInLine(doc As Word.Document, strFileName As String, strBookMark As String)
    Dim ilsh As Word.InlineShape
    
    Set ilsh = doc.InlineShapes.AddPicture(strFileName, , True, doc.Bookmarks(strBookMark).Range)
    ilsh.Height = CentimetersToPoints(3)
    ilsh.Width = CentimetersToPoints(4)
End Sub

Sub AddShape(doc As Word.Document, strFileName As String, strBookMark As String)
    Dim sh As Word.Shape
    
    Set sh = doc.Shapes.AddPicture(strFileName, , True, , , , , doc.Bookmarks(strBookMark).Range)
    sh.Top = CentimetersToPoints(1)
    sh.Left = CentimetersToPoints(2)
    sh.Height = CentimetersToPoints(3)
    sh.Width = CentimetersToPoints(4)
End Sub

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question