Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2007

Tip: Looking for answers? Try searching our database.

fix size of table cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SAM S.L - 07 Oct 2007 23:49 GMT
Hi!

It´s posible to fix the size of a cell in a table? I draw a table and insert
any images within, i like to mantain the size of the cells and autosize the
image to the limits of the cells

thanks

Sam
Jay Freedman - 08 Oct 2007 00:43 GMT
>Hi!
>
[quoted text clipped - 5 lines]
>
>Sam

First, I'll assume that your question has nothing to do with
UserForms, the topic of this newsgroup, and that you're doing this
manually through the menu system. Also, I have to assume that you have
Word 2003 or earlier; the instructions for Word 2007 and its ribbon
are a bit different (although the principle is the same).

Select the table and click Table > AutoFit > Fixed Column Width. Now
any picture you insert in a cell (formatted as In Line With Text, not
any of the floating text-wrapping types) will automatically be resized
to the width of the cell if its original size was larger. Pictures
that are smaller than the cell width will not be resized.

If, in addition to Fixed Column Width, you also go to Table > Table
Properties > Row and set an Exact measurement for the row height, the
inserted picture will be resized to fit that row height.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
SAM S.L - 08 Oct 2007 08:44 GMT
Ok.

I have a document formatted with a tables and textbox and protected, the
first textbox calls a userform. The userform collects data from the user and
his selections with textbox, combobox and checkbox, serch in the sql server
and calculate any valors. Last, the userform transfers inserted, calculated
and recollected data to the document, my problem is transfer any images
(with vba coding) to the formated cells of the tables without lose the size
of cells. I like the autosize the images not autosize the cells!

i use the next code for transfer images from userform to document, where
"signature" is a bookmark entry in the desired cell:

ActiveDocument.Bookmarks("signature").Select
Selection.InlineShapes.AddPicture FileName:="C:\PROJECT\TEST1\IMAgES\" &
TEST1.Fields("op_sign").Value & ".jpg", LinkToFile:=False,
SaveWithDocument:=True

Thanks for your comments!

Sam

>>Hi!
>>
[quoted text clipped - 30 lines]
> Email cannot be acknowledged; please post all follow-ups to the newsgroup
> so all may benefit.
Jay Freedman - 08 Oct 2007 19:04 GMT
This is a little more complicated than you might think at first. Not a lot,
just a little.

The first problem to work around is that you can't insert a picture at a
bookmark in a protected document while it's still protected. The code will
have to unprotect the document, insert the picture, and finally reprotect
the document (using an optional parameter of the .Protect method to prevent
all the fields from resetting to their default values).

The second thing isn't a problem, but a simplification. Since you'll be
using a table (with fixed column width) to hold the picture, you don't need
a bookmark to know where to put the picture. Also, it's poor practice to
move the insertion point and use the Selection object to insert the picture;
you can directly address the particular cell of the table without selecting
it.

As an example, add this to whatever other code is in your command button's
Click procedure:

   Const path = "C:\PROJECT\TEST1\IMAGES\"
   Dim oTbl As Table
   Dim oCel As Cell

   ' unprotect the form if needed
   If ActiveDocument.ProtectionType <> wdNoProtection Then
       ActiveDocument.Unprotect
   End If

   ' modify the next two lines if the table isn't the
   ' first one in the document, or if the signature
   ' goes in a different cell of the table
   Set oTbl = ActiveDocument.Tables(1)
   Set oCel = oTbl.Cell(1, 2)

   ' note the Range argument...
   ActiveDocument.InlineShapes.AddPicture _
       FileName:=path & TEST1.Fields("op_sign").Value & _
       ".jpg", LinkToFile:=False, SaveWithDocument:=True, _
       Range:=oCel.Range

   ' reprotect without resetting the fields to default values
   ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
       NoReset:=True

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> Ok.
>
[quoted text clipped - 52 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.