codewala

code it

Macro to import colored JPEG image as greyscale into Word

Following is the vba code to import JPEG image into word and then covert it into greyscale


'----------------------------------------------------------------------
Option Explicit
'
Sub ImportImageIntoWord()
'
Dim oDoc As Document
Dim docPath As String
Dim imgName As String
Dim imgPath As String
Dim wdInlineImage As InlineShape
'
Set oDoc = ActiveDocument
docPath = oDoc.path
'
imgName = "sunset.jpg"
imgPath = docPath & "\" & imgName
'
Set wdInlineImage = Selection.InlineShapes.AddPicture(imgPath, False, True)

wdInlineImage.ScaleWidth = 50
wdInlineImage.ScaleHeight = 50
'
wdInlineImage.PictureFormat.ColorType = msoPictureGrayscale
'
End Sub
'----------------------------------------------------------------------

Advertisements

January 4, 2011 - Posted by | VBA, Word

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: