VERSION 5.00 Begin VB.Form frmWordLink2 Caption = "Link to Word" ClientHeight = 5685 ClientLeft = 45 ClientTop = 330 ClientWidth = 7410 LinkTopic = "Form1" ScaleHeight = 5685 ScaleWidth = 7410 StartUpPosition = 3 'Windows Default Begin VB.TextBox txtDonation Height = 288 Left = 1560 TabIndex = 13 Top = 1680 Width = 1092 End Begin VB.TextBox txtAddress Height = 288 Index = 3 Left = 3120 TabIndex = 8 Top = 1200 Width = 1092 End Begin VB.TextBox txtAddress Height = 288 Index = 2 Left = 1560 TabIndex = 7 Top = 1200 Width = 1572 End Begin VB.TextBox txtAddress Height = 288 Index = 1 Left = 1560 TabIndex = 6 Top = 840 Width = 2172 End Begin VB.TextBox txtAddress Height = 288 Index = 0 Left = 1560 TabIndex = 5 Top = 480 Width = 2172 End Begin VB.ComboBox comTitle Height = 288 ItemData = "frmWordLink2.frx":0000 Left = 1560 List = "frmWordLink2.frx":0013 TabIndex = 4 Top = 120 Width = 732 End Begin VB.TextBox txtName Height = 288 Index = 1 Left = 3240 TabIndex = 3 Top = 120 Width = 1092 End Begin VB.TextBox txtName Height = 288 Index = 0 Left = 2280 TabIndex = 2 Top = 120 Width = 972 End Begin VB.CommandButton cmdExit Caption = "E&xit" Height = 612 Left = 2280 TabIndex = 1 Top = 4560 Width = 1212 End Begin VB.CommandButton CmdToWord Caption = "&Create Letter" Height = 612 Left = 480 TabIndex = 0 Top = 4560 Width = 1212 End Begin VB.Label lblDonation Caption = "Donation" Height = 252 Left = 120 TabIndex = 12 Top = 1680 Width = 852 End Begin VB.Label lblCtyPostcode Caption = "County/Postcode" Height = 252 Left = 120 TabIndex = 11 Top = 1200 Width = 1452 End Begin VB.Label lblAddress Caption = "Address" Height = 252 Left = 120 TabIndex = 10 Top = 480 Width = 732 End Begin VB.Label lblName Caption = "Name" Height = 252 Left = 120 TabIndex = 9 Top = 120 Width = 732 End End Attribute VB_Name = "frmWordLink2" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim w1 As Word.Application Dim d1 As Word.Document Sub Thankyou() ' ' Thankyou Macro ' code identified by recording a macro in Word donation = txtDonation.Text DonorName = comTitle.Text + " " + Trim(txtName(0).Text) + " " + Trim(txtName(1).Text) CountyLine = Trim(txtAddress(2).Text) + " " + Trim(txtAddress(3).Text) ' Trim is used to get rid of unwanted spaces at the beginning or end of text Salutation = "Dear " + comTitle.Text + " " + Trim(txtName(1).Text) Message = "We would like to confirm your booking..........." Message = Message + " " + Format(donation, " ") + "." ' With w1.Selection .TypeParagraph .TypeParagraph .Font.Size = 12 .Font.Name = "arial" .TypeText Text:=DonorName .TypeParagraph .TypeText Text:=txtAddress(0).Text .TypeParagraph .TypeText Text:=txtAddress(1).Text .TypeParagraph .TypeText Text:=CountyLine .TypeParagraph .InsertDateTime DateTimeFormat:="dddd, dd MMMM yyyy", _ InsertAsField:=False .TypeParagraph .TypeParagraph .TypeText Text:=Salutation .TypeParagraph .TypeParagraph .TypeText Text:=Message .TypeParagraph .TypeParagraph .TypeText Text:="Yours Faithfully" .TypeParagraph .TypeParagraph .TypeParagraph .TypeParagraph .TypeParagraph .TypeParagraph .TypeText Text:="Vicky Jones" End With End Sub Private Sub CmdToWord_Click() ' Defines two objects that enable Word to be ' accessed and manipulated Set w1 = CreateObject("Word.Application") ' allows Word to be opened With w1 .Visible = True .Application.WindowState = wdWindowStateMaximize Set d1 = .Documents.Add("advantage.dot") ' Blue party was created as a template file and stored in the directory ' C:\Program Files\Microsoft Office\Templates ' This opens a new document using that template Thankyou ' runs the routine entered in general section which ' copies the text from the box into the Word document End With End Sub Private Sub cmdExit_Click() End End Sub