Solved

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

Posted on 2012-03-30
1
416 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 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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