Results 1 to 3 of 3
2012-06-06, 14:31 #1
- Join Date
- May 2012
- Thanked 0 Times in 0 Posts
Automatically size insert picture in Word 2003 protected document form
Hi there --
I am brand new to this type of forum, and offered to make a form for my work. All was going well with the fields and such, and protecting the document, until I hit a snag in the "insert picture" feature. They want to be able to insert a picture in the protected document and have it come in as a pre-determined size, in other words, most pics will have to shrink to fit the document. I've got to do this for (50) photos (2 per page, so a 25-page document). Here is what I have so far, attached. PictureSample1.doc
I searched on here and found a template which I downloaded, that allows the user to "double-click to insert picture" while the doc is in it's protected state, and that part is working well. (Not that I can find that thread again now that it's been a few days, otherwise I would have posted in there.) Now I just need it to automatically size them when it does so.
I don't want to bother with creating section breaks if I can just have a macro that will work instead.
Here is the macro code for the above that I downloaded, and I was hoping someone could just expand on it where it needs the sizing information:
Option Explicit Sub InsertPic1() InsertPic 1 End Sub Sub InsertPic2() InsertPic 2 End Sub Sub InsertPic3() InsertPic 3 End Sub Sub InsertPic(n As Integer) Dim sFileName As String Dim ilImage As InlineShape Dim rng As Range If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then ActiveDocument.Unprotect End If With Dialogs(wdDialogInsertPicture) .Display If .Name <> "" Then sFileName = .Name Set rng = ActiveDocument.Bookmarks("Pic" & n).Range Set ilImage = ActiveDocument.InlineShapes.AddPicture(sFileName, , True, rng) With ilImage 'set any additional properties such as left, top, etc., here End With End If End With ActiveDocument.Protect wdAllowOnlyFormFields, True End Sub
Any and all help would be appreciated!! I've been sitting on this for 2 days now, stuck at the same point.
Last edited by macropod; 2012-06-06 at 20:21. Reason: Changed Indent tags to Code tags
2012-06-06, 20:19 #2
- Join Date
- May 2002
- Canberra, Australian Capital Territory, Australia
- Thanked 420 Times in 349 Posts
If you create a single-cell table of the appropriate size, with fixed column width and row height, any picture you insert into that table will be constrained to fit the available space.
PS: When posting code, please use the code tags.Cheers,
[MS MVP - Word]
2012-06-06, 20:41 #3
- Join Date
- Mar 2004
- Manning, South Carolina
- Thanked 1,473 Times in 1,340 Posts