PDA

View Full Version : Newbie Help - Userform



jamestregg
10-16-2017, 04:50 PM
Hi,

I am tyring to set up a contract document with a userform in word to enter all the input information throughout the document. all fields are setup in the document and the reference names are all correct however I am getting an issue with my code when I run it, which is no surprise really!

If anyone could give me some assistance, it would be much appreciated!


Option Explicit

Private Sub UserForm_Initialize()
With cboWorks_Ins
.AddItem "Alternative 1"
.AddItem "Alternative 2"
End With
With cboPL_Ins
.AddItem "Alternative 1"
.AddItem "Alternative 2"
End With
With cboPC_Date_Time
.AddItem "Date"
.AddItem "Duration (in weeks)"
End With
End Sub


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


Private Sub cmdOK_Click()

Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("Project_No").Range.Text = txtProject_No.Value
.Bookmarks("Proj_Name").Range.Text = txtProj_Name.Value
.Bookmarks("Client").Range.Text = txtClient.Value
.Bookmarks("Client_Address").Range.Text = txtClient_Address.Value
.Bookmarks("Client_ABN").Range.Text = txtClient_ABN.Value
.Bookmarks("Council").Range.Text = txtCouncil.Value
.Bookmarks("Water_Auth").Range.Text = txtWater_Auth.Value
.Bookmarks("Elect_Auth").Range.Text = txtElect_Auth.Value
.Bookmarks("Main_Drain_Auth").Range.Text = txtMain_Drain_Auth.Value
.Bookmarks("Comms_Auth").Range.Text = txtComms_Auth.Value
.Bookmarks("Tender_Close").Range.Text = txtTender_CLose.Value
.Bookmarks("LDs").Range.Text = txtLDs.Value
.Bookmarks("Works_Ins").Range.Text = cboWorks_Ins.Value
.Bookmarks("PL_Ins").Range.Text = cboPL_Ins.Value
.Bookmarks("Possession_Time").Range.Text = txtPossession_Time.Value
.Bookmarks("Possession_Trigger").Range.Text = txtPossession_Trigger.Value
.Bookmarks("PC_Date_Time").Range.Text = cboPC_Date_Time.Value
.Bookmarks("PC").Range.Text = txtPC.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub

SamT
10-16-2017, 05:26 PM
I think the *cough cough* error is in the *cough cough* line

Paul_Hossler
10-16-2017, 05:26 PM
Welcome to the forum

I added CODE tags around your macro for formatting and readability -- use the [#] next time


I am getting an issue with my code when I run it,

Afraid that doesn't help much

Can you attach a sanitized (if necessary) document that shows the issue?

My sig has instructions

Paul_Hossler
10-16-2017, 05:27 PM
Ninja-ed by SamT again

SamT
10-17-2017, 06:27 AM
I dint see nuttin in dat code dat jumped up an said "I'm bad!"