Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Building a word document in vb.net - Ability to format the header jpg.

Posted on 2012-03-30
1
Medium Priority
?
429 Views
Last Modified: 2012-06-21
With the code below I am able to add the jpg file to the word document header but I am unable to modify.  I need the ability to format the picture to Horizontal Alignment = Left and wrapping style = Behind Text, and adjust the size of the photo to include the entire width of the document.

oWord.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader

 oWord.ActiveWindow.Selection.InlineShapes.AddPicture(FileName:="G:\apps\EXECSRCH\header.jpg", LinkToFile:=False, SaveWithDocument:=True)

Any help would be greatly appreciated.

Thank you,
Vince
0
Comment
Question by:wittkieffer
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 37813220
The first thing that I try to do when working with VBA or .NET equivalent, is to record a macro.

Setting the format for a picture would be:

 Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

Open in new window


You need a reference to the Shape object to set the properties:

With Selection.ShapeRange
   .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
   .Left = wdShapeCenter
   .WrapFormat.Type = wdWrapTight
   .LockAspectRatio = msoTrue
   .ScaleHeight 0.8, msoTrue
   .ScaleHeight 0.8, msoTrue
End With

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

783 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