Log in

View Full Version : Automated Letterheads



KyleN
03-05-2012, 07:14 AM
Hi guys,

I'm developing an automated letterhead, with OptionButtons - and I've developed it to a point where the user can select their office from the list of options, and it will string the address of the office in the chosen Bookmark...

However, I would also like it to add the correct logo of that office to a Bookmark in the document - Is this possible?

Here is the code I have so far:




Private Sub cmdCancel_Click()
Unload Me
ActiveDocument.Close SaveChanges:=False
End Sub

Private Sub CmdOK_Click()
Dim StrOffice As String
If OptionButton1 = True Then StrOffice = "C:\Users\kylen\Desktop\The-Community-Housing-Group.png"
If OptionButton2 = True Then StrOffice = "Community House | Stourport Road | Kidderminster | Worcestershire | DY11 7QE"
If OptionButton3 = True Then StrOffice = "38 High Street | Stourport-on-Severn | Worcestershire | DY13 8BS"
If OptionButton4 = True Then StrOffice = "Kidderminster Town Hall | Vicar Street | Kidderminster | Worcestershire | DY10 1DB"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("Name").Range.Text = txtName.Value
.Bookmarks("JobTitle").Range.Text = txtJobTitle.Value
.Bookmarks("Office").Range.Text = StrOffice
.Bookmarks("Tel").Range.Text = txtTel.Value
.Bookmarks("Email").Range.Text = txtEmail.Value
.Bookmarks("Ref").Range.Text = txtRef.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub

Private Sub UserForm_Initialize()
OptionButton1.Value = True
End Sub


Thanks, Kyle :)

gmaxey
03-05-2012, 12:21 PM
Kyle,

Not specifically targeting a userform but the basic idea is covered here where a a graphic is inserted at a bookmark based on a content control selection:

http://gregmaxey.mvps.org/word_tip_pages/insert_content_with_content_controls.html