By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Picture manipulation in vb

P: 8
hi all,
i just exported the pic from msflex to word document in a table. now, i want to fit the size of the image in one column. either the size of the image is small or large, it should be fit in the column with the height and the width that i have decided.
can it b done,
i use the following code to have picture in the word, but i wanna fix the dimension of the image so that even the size varies, it does not cross the declared size. it has to fit in the size that is declared in the code.

the code is:

oDoc.Tables(1).Columns(1).Cells(w).Range.InlineSha pes.AddPicture FileName:=fg.TextMatrix(i, 3), SaveWithDocument:=True

thanx in advance
May 9 '07 #1
Share this Question
Share on Google+
4 Replies


SammyB
Expert 100+
P: 807
Before you add the picture, setup the table so that it will not auto-scale. Something like this:
Expand|Select|Wrap|Line Numbers
  1.     ActiveDocument.Tables(1) .Rows.HeightRule = wdRowHeightExactly
  2.     ActiveDocument.Tables(1) .Rows.Height = CentimetersToPoints(5)
  3.     ActiveDocument.Tables(1) .Columns.PreferredWidthType = wdPreferredWidthPoints
  4.     ActiveDocument.Tables(1) .Columns.PreferredWidth = CentimetersToPoints(4)
  5.     ActiveDocument.Tables(1) .AutoFitBehavior wdAutoFitFixed
  6.     ActiveDocument.Tables(1) .Cell(2, 1).Range.InlineShapes.AddPicture FileName:= _
  7.         "C:\Documents and Settings\Sam\My Documents\My Pictures\CoffsHarbour.jpg", _
  8.         LinkToFile:=False, SaveWithDocument:=True
BTW, I know next to nothing about Word. I just recorded several macros of playing with the Table properties, then used Intellisense until I had something that worked. You too can be an "expert" ! ;) Sam
May 10 '07 #2

Expert 5K+
P: 8,434
Expand|Select|Wrap|Line Numbers
  1. ActiveDocument.Tables(1) .Rows.Height = CentimetersToPoints(5)
  2. ActiveDocument.Tables(1) .Columns.PreferredWidthType = wdPreferredWidthPoints
sayamishiraj, be aware that TheScripts has inserted some spaces into this code which don't belong there. (I've underlined them in a couple of samples above to show what I mean). If you copy this code you will need to correct it.
May 11 '07 #3

SammyB
Expert 100+
P: 807
sayamishiraj, be aware that TheScripts has inserted some spaces into this code which don't belong there. (I've underlined them in a couple of samples above to show what I mean). If you copy this code you will need to correct it.
Actually, I inserted the spaces where VBA won't care, so that TheScripts won't put a space where it will cause an error. ;)
May 11 '07 #4

Expert 5K+
P: 8,434
Oops !
May 11 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.