Supportnet Computer
Planet of Tech

Supportnet / Forum / Textverarbeitung

Word Formular mit Bild versehen...





Frage

Hallo, und zwar hab ich folgendes Problem: Ich hab ein Formular in Word erstellt und möchte, das derjenige, der es später ausfüllt in das Formular ein Bild einfügen kann - ohne das er diesen Formular Modus ausschalten muss! Bitte, bitte helft mir ;-) Gruß ck

Antwort 1 von Lisa2004

Öffne den Visual Basic Editor - Einfügen Modul - Kopiere das Macro unten und füge es ein - Speichern, dann füge in Dein Dokument ein Feld ein - MacroButton - wähle das Makro ProtectedInsertPicture aus - hinzufügen - schreibe dahinter den Text der angezeigt werden soll z.B. hier klicken und Bild einfügen - ok. Wenn der Benutzer jetzt auf den Text hier klicken ... klickt kann er ein Bild einfügen. Das heisst, der Dokumentschutz wird für das Einfügen des Bildes kurz aufgehoben, wenn er das Feld verlässt, ist es wieder geschützt.




Public Sub ProtectedInsertPicture()
Dim ilsPicture As InlineShape
Dim strFileName As String
Dim sngRatio As Single
Const max_width = 216 ' = 3 inches (in points)

' temporarily unprotect
ActiveDocument.Unprotect

' show Insert Picture dialog
With Dialogs(wdDialogInsertPicture)
If .Display = 0 Then Exit Sub
strFileName = .Name
End With

' remove macrobutton
Selection.Delete

Set ilsPicture = ActiveDocument.InlineShapes _
.AddPicture( _
FileName:=strFileName, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Range:=Selection.Range)

' limit size of picture to max_width (optional)
With ilsPicture
If .Width > max_width Then
sngRatio = CSng(max_width) / .Width
.Width = max_width
.Height = .Height * sngRatio
End If
End With

' reprotect, keeping form field contents intact
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True

' show Insert Picture dialog
With Dialogs(wdDialogInsertPicture)
If .Display = 0 Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True
Exit Sub
End If
strFileName = .Name
End With

End Sub


Gruß Lisa

Ich möchte kostenlos eine Frage an die Mitglieder stellen:


Ähnliche Themen:


Suche in allen vorhandenen Beiträgen: