![]() |
|
#1
|
|||
|
|||
|
I have created a table within Microsoft Word 2007 to hold photographs as a secondary user document. I will be leaving the photograph control blank to be modified with insertion by the using party. What I need to accomplish is "locking" the photograph and/or table so that when the user clicks on the pane in the table that they wish to use the control for the photograph, they cannot rotate, resize, move, etc. the photograph.
I still require the user to be able to modify Rich Text boxes throughout the document to "rename" the photographs they are inserting. Thank you in advance for any assistance you may be able to provide. Brandon |
|
#2
|
||||
|
||||
|
Hi Brandon,
If you: • use a table with fixed row heights and column widths; • apply editing restrictions a ContentControlOnExit macro can be used to limit what users can do with the inserted pictures. For installation instructions, see: http://www.gmayor.com/installing_macro.htm Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim iShp As InlineShape, TblCell As Cell, StrPwd As String, Prot
StrPwd = "" 'password
With ActiveDocument
Prot = .ProtectionType
If Prot <> wdNoProtection Then .Unprotect StrPwd
End With
With ContentControl
If .Type = wdContentControlPicture And .Range.Information(wdWithInTable) Then
With .Range
Set TblCell = .Cells(1)
If .ShapeRange.Count > 0 Then
With .ShapeRange(1)
.LockAspectRatio = msoTrue
.Width = TblCell.Width
If .Height > TblCell.Height Then .Height = TblCell.Height
End With
GoTo ShpExit
End If
Set iShp = TblCell.Range.InlineShapes(1)
iShp.LockAspectRatio = msoTrue
iShp.Width = TblCell.Width
If iShp.Height > TblCell.Height Then iShp.Height = TblCell.Height
.ParagraphFormat.LeftIndent = TblCell.LeftPadding * -1
End With
End If
End With
ShpExit:
If Prot <> wdNoProtection Then
ActiveDocument.Protect Type:=Prot, NoReset:=True, Password:=StrPwd
End If
Application.ScreenUpdating = True
End Sub
Now for some caveats: Even if you use a ContentControlOnExit macro, the user can still rotate the picture, but they could do that outside Word, anyway. More importantly, if • Word’s picture insertion mode (File|Options|Advanced>Cut,Copy,Paste) is other than in-line; and • the user uses the Insert|Picture dialogue (which is not disabled when editing restrictions are applied) to insert the picture instead of doing so by double-clicking on the Content Control, the user can drag the picture to wherever they want, provided it's top is lower than the top of the cell concerned. When they do, the picture will still snap back to within the cell's horizontal alignment, but it ignores the vertical alignment altogether and there seems to be no way to correct it in code – I’ve tried all manner of adjustments to the .Top value and .RelativeVerticalPosition settings and the picture sullenly remains wherever it was dragged to – even below the table. See attached file.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| image insert, restrictions, table control |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Move Picture by picture name, rename picture by picture name | CatMan | PowerPoint | 2 | 04-18-2012 12:21 PM |
| Powerpoint automatically changing picture size when adding a picture (2010) | One_Life | PowerPoint | 7 | 01-20-2012 06:57 AM |
| How to modify the citation format | MREGLIER | Word | 0 | 02-19-2011 03:31 AM |
| Disable/Modify MOC.exe | worthydaydream | Office | 3 | 04-23-2010 10:43 AM |
Modify an AppointmentItem in someone else's Calendar
|
humpra | Outlook | 1 | 10-16-2009 03:35 AM |