Picture manipulation in vb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sayamishiraj
    New Member
    • Mar 2007
    • 8

    Picture manipulation in vb

    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).Cell s(w).Range.Inli neShapes.AddPic ture FileName:=fg.Te xtMatrix(i, 3), SaveWithDocumen t:=True

    thanx in advance
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    #2
    Before you add the picture, setup the table so that it will not auto-scale. Something like this:
    Code:
    	ActiveDocument.Tables(1) .Rows.HeightRule = wdRowHeightExactly
    	ActiveDocument.Tables(1) .Rows.Height = CentimetersToPoints(5)
    	ActiveDocument.Tables(1) .Columns.PreferredWidthType = wdPreferredWidthPoints
    	ActiveDocument.Tables(1) .Columns.PreferredWidth = CentimetersToPoints(4)
    	ActiveDocument.Tables(1) .AutoFitBehavior wdAutoFitFixed
    	ActiveDocument.Tables(1) .Cell(2, 1).Range.InlineShapes.AddPicture FileName:= _
    		"C:\Documents and Settings\Sam\My Documents\My Pictures\CoffsHarbour.jpg", _
    		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

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by SammyB
      Code:
      ActiveDocument.Tables(1[U]) .[/U]Rows.Height = CentimetersToPoints(5)
      ActiveDocument.Tables(1[U]) .[/U]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.

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #4
        Originally posted by Killer42
        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. ;)

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Oops !

          Comment

          Working...