Hi guys, bit of a n00b when it comes to VBA but i had a dabble and created a wizard for a standard letter for Word. It works fine but the code is rather long winded. Could anyone help me streamline this code please...
Private Sub CMDok_Click()
Selection.GoTo what:=wdGoToBookmark, Name:="companyname"
Selection.TypeText TXTcompname.Text
Selection.GoTo what:=wdGoToBookmark, Name:="address1"
Selection.TypeText TXTaddress1.Text
Selection.GoTo what:=wdGoToBookmark, Name:="address2"
Selection.TypeText TXTaddress2.Text
Selection.GoTo what:=wdGoToBookmark, Name:="address3"
Selection.TypeText TXTaddress3.Text
Selection.GoTo what:=wdGoToBookmark, Name:="Postcode"
Selection.TypeText TXTpostcode.Text
Selection.GoTo what:=wdGoToBookmark, Name:="FAOtitle"
Selection.TypeText CMBOXtitle.Text
Selection.Font.Name = "Arial"
Selection.Font.Size = 11
Selection.Font.Bold = False
Selection.GoTo what:=wdGoToBookmark, Name:="FAOname"
Selection.TypeText TXTfaoname.Text
Selection.Font.Name = "Arial"
Selection.Font.Size = 11
Selection.Font.Bold = False
Selection.GoTo what:=wdGoToBookmark, Name:="subject"
Selection.TypeText TXTsubject.Text
Selection.GoTo what:=wdGoToBookmark, Name:="signoff"
Selection.TypeText CMBOXsignoff.Text
Selection.GoTo what:=wdGoToBookmark, Name:="sendername"
Selection.TypeText TXTsendername.Text
Selection.GoTo what:=wdGoToBookmark, Name:="Ourref"
Selection.TypeText TXTourref.Text
Selection.GoTo what:=wdGoToBookmark, Name:="Yourref"
Selection.TypeText TXTyourref.Text
Selection.GoTo what:=wdGoToBookmark, Name:="sendertitle"
If CMBOXsendertitle.Text = "Other" Then
Selection.TypeText TXTothertitle.Text
Else
Selection.TypeText CMBOXsendertitle.Text
End If
If CHKBXencs.Value = "True" Then
Selection.GoTo what:=wdGoToBookmark, Name:="Enclosements"
Selection.TypeText Text:="encs."
Else
Selection.TypeText Text:=""
End If
Selection.GoTo what:=wdGoToBookmark, Name:="Date"
Selection.InsertDateTime DateTimeFormat:="dd MMMM, yyyy", _
InsertAsField:=True
Frminformation.Hide
End Sub
Seems a bit much for me but if thats the best its going to get then ill live with it
Thanks in advance
Dave
Private Sub CMDok_Click()
Selection.GoTo what:=wdGoToBookmark, Name:="companyname"
Selection.TypeText TXTcompname.Text
Selection.GoTo what:=wdGoToBookmark, Name:="address1"
Selection.TypeText TXTaddress1.Text
Selection.GoTo what:=wdGoToBookmark, Name:="address2"
Selection.TypeText TXTaddress2.Text
Selection.GoTo what:=wdGoToBookmark, Name:="address3"
Selection.TypeText TXTaddress3.Text
Selection.GoTo what:=wdGoToBookmark, Name:="Postcode"
Selection.TypeText TXTpostcode.Text
Selection.GoTo what:=wdGoToBookmark, Name:="FAOtitle"
Selection.TypeText CMBOXtitle.Text
Selection.Font.Name = "Arial"
Selection.Font.Size = 11
Selection.Font.Bold = False
Selection.GoTo what:=wdGoToBookmark, Name:="FAOname"
Selection.TypeText TXTfaoname.Text
Selection.Font.Name = "Arial"
Selection.Font.Size = 11
Selection.Font.Bold = False
Selection.GoTo what:=wdGoToBookmark, Name:="subject"
Selection.TypeText TXTsubject.Text
Selection.GoTo what:=wdGoToBookmark, Name:="signoff"
Selection.TypeText CMBOXsignoff.Text
Selection.GoTo what:=wdGoToBookmark, Name:="sendername"
Selection.TypeText TXTsendername.Text
Selection.GoTo what:=wdGoToBookmark, Name:="Ourref"
Selection.TypeText TXTourref.Text
Selection.GoTo what:=wdGoToBookmark, Name:="Yourref"
Selection.TypeText TXTyourref.Text
Selection.GoTo what:=wdGoToBookmark, Name:="sendertitle"
If CMBOXsendertitle.Text = "Other" Then
Selection.TypeText TXTothertitle.Text
Else
Selection.TypeText CMBOXsendertitle.Text
End If
If CHKBXencs.Value = "True" Then
Selection.GoTo what:=wdGoToBookmark, Name:="Enclosements"
Selection.TypeText Text:="encs."
Else
Selection.TypeText Text:=""
End If
Selection.GoTo what:=wdGoToBookmark, Name:="Date"
Selection.InsertDateTime DateTimeFormat:="dd MMMM, yyyy", _
InsertAsField:=True
Frminformation.Hide
End Sub
Seems a bit much for me but if thats the best its going to get then ill live with it

Thanks in advance
Dave