Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now