PDA

View Full Version : Sharing a word userform



katenardy
02-24-2013, 02:10 PM
Hello Everyone,

I'm very new to VBA, requiring for my new job, and I'm hoping that my problem will be very straightforward to fix.

I have created a userform using instructions I have found on the internet and it is working very well on my computer. The user form opens automatically when I open the document, I have made a macro so there is a button at the top of my word to open the form and it all works fine. My problem is that I'm trying to share the userform I made with my colleagues on our network and I just cannot get the document to take the code with it. I couldn't email it to you if I wanted to, but yet it works perfectly fine on my computer.

We are a little outdated here, so I am using word 2000, however a previous staff member has created documents like this that we have had no trouble sharing.

I really hope you can help! : pray2:

Here is my code:
This document:
Sub AutoOpen()
Call FrmErectorSheetNormal.Show

End Sub



Userform:
Private Sub cmdClear_Click()
cboErectoronSite.Value = Null
cbobobcattime.Value = Null
cboconcretetime.Value = Null
cboCraneTime.Value = Null
cboDeliveryTime.Value = Null
cboErectorsTime.Value = Null
cboPowerMetrestoSiteClientGeneratorwithFuel.Value = Null
cboShedPositionPegged.Value = Null
cboTimbersPJNCLIENT.Value = Null
cbocouncil.Value = Null
cboconcrete.Value = Null
cbobobcat.Value = Null
cbocrane.Value = Null
BinsCheckBox.Value = Null
ForksCheckBox.Value = Null
HazardAssessmentCheckBox.Value = Null
ShedPositionPeggedCheckBox.Value = Null
SiteDoneCheckBox.Value = Null
SiteLevelCheckBox.Value = Null
TruckAccessCheckBox.Value = Null
txtAdditionalNotes.Value = Null
txtBobcatdate.Value = Null
txtBobcatFootings1.Value = Null
txtbobcatfootings2.Value = Null
txtbobcatnote.Value = Null
txtChanceOfStrikingRock.Value = Null
txtClientMobile.Value = Null
txtClientName.Value = Null
txtClientPhone.Value = Null
txtconcretecubicmetres.Value = Null
txtconcretedate.Value = Null
txtconcretenote.Value = Null
txtcouncil.Value = Null
txtCraneDate.Value = Null
txtCraneNote.Value = Null
txtDeliveryDate.Value = Null
txtDeliveryNotes.Value = Null
txtErectorsExpected.Value = Null
txtForkCapacity.Value = Null
txtPowermetrestosite.Value = Null
txtshedpositionpegged.Value = Null
txtsitelevel.Value = Null
cbotruckaccess.Value = Null
txtErectorNote.Value = Null
ScissorCB.Value = Null
txtNFS.Value = Null
txtdfs.Value = Null
cbost.Value = Null
FenceCheckBox.Value = Null
cboPJNCLIENTSCISSOR.Value = Null
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdRecord_Click()
Dim strBins As String
Dim strChanceofStrikingRock As String
Dim strforkswithoperator As String
Dim strhazardassessment As String
Dim strshedpositionpegged As String
Dim strsitedone As String
Dim strsitelevel As String
Dim strtruckaccess As String
Dim strscissor As String
Dim strfence As String
If BinsCheckBox = True Then strBins = "R"
If BinsCheckBox = False Then strBins = ""
If ChanceofStrikingRockCheckBox = True Then strChanceofStrikingRock = "R"
If ChanceofStrikingRockCheckBox = False Then strChanceofStrikingRock = ""
If ForksCheckBox = True Then strforkswithoperator = "R"
If ForksCheckBox = False Then strforkswithoperator = ""
If HazardAssessmentCheckBox = True Then strhazardassessment = "R"
If HazardAssessmentCheckBox = False Then strhazardassessment = ""
If ShedPositionPeggedCheckBox = True Then strshedpositionpegged = "R"
If ShedPositionPeggedCheckBox = False Then strshedpositionpegged = ""
If SiteDoneCheckBox = True Then strsitedone = "R"
If SiteDoneCheckBox = False Then strsitedone = ""
If SiteLevelCheckBox = True Then strsitelevel = "R"
If SiteLevelCheckBox = False Then strsitelevel = ""
If TruckAccessCheckBox = True Then strtruckaccess = "R"
If TruckAccessCheckBox = False Then strtruckaccess = ""
If ScissorCB = True Then strscissor = "SCISSOR"
If ScissorCB = False Then strscissor = ""
If FenceCheckBox = True Then strfence = "R"
If FenceCheckBox = False Then strfence = ""
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("AdditionalJobNotes").Range.Text = txtAdditionalNotes.Value
.Bookmarks("bins").Range.Text = strBins
.Bookmarks("bobcatborer").Range.Text = txtbobcatnote.Value
.Bookmarks("bobcatborerdate").Range.Text = txtBobcatdate.Value
.Bookmarks("bobcatborertime").Range.Text = cbobobcattime.Value
.Bookmarks("PJNCLIENT").Range.Text = cbobobcat.Value
.Bookmarks("CanSiteHandleWet").Range.Text = cbositewet.Value
.Bookmarks("ChanceofStrikingRock").Range.Text = strChanceofStrikingRock
.Bookmarks("ChanceofStrikingRocknote").Range.Text = txtChanceOfStrikingRock.Value
.Bookmarks("ClientMobile").Range.Text = txtClientMobile.Value
.Bookmarks("ClientName").Range.Text = txtClientName.Value
.Bookmarks("ClientPhone").Range.Text = txtClientPhone.Value
.Bookmarks("ConcreteCubicMetres").Range.Text = txtconcretecubicmetres.Value
.Bookmarks("ConcreteDate").Range.Text = txtconcretedate.Value
.Bookmarks("ConcreteNote").Range.Text = txtconcretenote.Value
.Bookmarks("ConcreteTime").Range.Text = cboconcretetime.Value
.Bookmarks("Council").Range.Text = txtcouncil.Value
.Bookmarks("CraneAdditionalNote").Range.Text = txtCraneNote.Value
.Bookmarks("CraneDate").Range.Text = txtCraneDate.Value
.Bookmarks("CraneTime").Range.Text = cboCraneTime.Value
.Bookmarks("DateErectorsExpected").Range.Text = txtErectorsExpected.Value
.Bookmarks("DeliveryDate").Range.Text = txtDeliveryDate.Value
.Bookmarks("DeliveryNote").Range.Text = txtDeliveryNotes.Value
.Bookmarks("Erector").Range.Text = cboErectoronSite.Value
.Bookmarks("ErectorNote").Range.Text = txtErectorNote.Value
.Bookmarks("Footings1").Range.Text = txtBobcatFootings1.Value
.Bookmarks("Footings2").Range.Text = txtbobcatfootings2.Value
.Bookmarks("ForksCapacity").Range.Text = txtForkCapacity.Value
.Bookmarks("ForksWithOperator").Range.Text = strforkswithoperator
.Bookmarks("HazardAssessment").Range.Text = strhazardassessment
.Bookmarks("PJNCLIENT2").Range.Text = cbocouncil.Value
.Bookmarks("PJNCLIENT3").Range.Text = cboconcrete.Value
.Bookmarks("PJNCLIENT4").Range.Text = cbocrane.Value
.Bookmarks("Power").Range.Text = cboPowerMetrestoSiteClientGeneratorwithFuel.Value
.Bookmarks("PowerMetrestoSite").Range.Text = txtPowermetrestosite.Value
.Bookmarks("ShedPositionPegged").Range.Text = strshedpositionpegged
.Bookmarks("ShedPositionPeggedClientThere").Range.Text = cboShedPositionPegged.Value
.Bookmarks("ShedPositionPeggedClientThereNote").Range.Text = txtshedpositionpegged.Value
.Bookmarks("SiteDone").Range.Text = strsitedone
.Bookmarks("SiteLevel").Range.Text = strsitelevel
.Bookmarks("SiteLevelNote").Range.Text = txtsitelevel.Value
.Bookmarks("Timbers").Range.Text = cboTimbersPJNCLIENT.Value
.Bookmarks("TruckAccess").Range.Text = strtruckaccess
.Bookmarks("TruckAccessNote").Range.Text = cbotruckaccess.Value
.Bookmarks("DeliveryTime").Range.Text = cboDeliveryTime.Value
.Bookmarks("ErectorTime").Range.Text = cboErectorsTime.Value
.Bookmarks("HazardAssessmentBox").Range.Text = cbohazard.Value
.Bookmarks("Fence").Range.Text = strfence
.Bookmarks("Scissor").Range.Text = strscissor
.Bookmarks("ScissorDate").Range.Text = txtdfs.Value
.Bookmarks("ScissorNote").Range.Text = txtNFS.Value
.Bookmarks("PJNCLIENT5").Range.Text = cboPJNCLIENTSCISSOR.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub



Private Sub UserForm_Initialize()
With cboErectoronSite
.AddItem "Nick Black 0408 691 520"
.AddItem "Phil Hansen 0425 269 010"
End With
With cbobobcattime
.AddItem "7am"
.AddItem "7.30am"
.AddItem "8am"
.AddItem "8.30am"
.AddItem "9am"
.AddItem "10am"
.AddItem "10.30am"
.AddItem "11am"
.AddItem "11.30am"
.AddItem "12pm"
.AddItem "12.30pm"
.AddItem "1pm"
.AddItem "1.30pm"
.AddItem "2pm"
.AddItem "2.30pm"
.AddItem "3pm"
.AddItem "3.30pm"
.AddItem "4pm"
.AddItem "4.30pm"
.AddItem "5pm"
.AddItem "5.30pm"
End With
With cboconcretetime
.AddItem "7am"
.AddItem "7.30am"
.AddItem "8am"
.AddItem "8.30am"
.AddItem "9am"
.AddItem "10am"
.AddItem "10.30am"
.AddItem "11am"
.AddItem "11.30am"
.AddItem "12pm"
.AddItem "12.30pm"
.AddItem "1pm"
.AddItem "1.30pm"
.AddItem "2pm"
.AddItem "2.30pm"
.AddItem "3pm"
.AddItem "3.30pm"
.AddItem "4pm"
.AddItem "4.30pm"
.AddItem "5pm"
.AddItem "5.30pm"
End With
With cboCraneTime
.AddItem "7am"
.AddItem "7.30am"
.AddItem "8am"
.AddItem "8.30am"
.AddItem "9am"
.AddItem "10am"
.AddItem "10.30am"
.AddItem "11am"
.AddItem "11.30am"
.AddItem "12pm"
.AddItem "12.30pm"
.AddItem "1pm"
.AddItem "1.30pm"
.AddItem "2pm"
.AddItem "2.30pm"
.AddItem "3pm"
.AddItem "3.30pm"
.AddItem "4pm"
.AddItem "4.30pm"
.AddItem "5pm"
.AddItem "5.30pm"
End With
With cboDeliveryTime
.AddItem "7am"
.AddItem "7.30am"
.AddItem "8am"
.AddItem "8.30am"
.AddItem "9am"
.AddItem "10am"
.AddItem "10.30am"
.AddItem "11am"
.AddItem "11.30am"
.AddItem "12pm"
.AddItem "12.30pm"
.AddItem "1pm"
.AddItem "1.30pm"
.AddItem "2pm"
.AddItem "2.30pm"
.AddItem "3pm"
.AddItem "3.30pm"
.AddItem "4pm"
.AddItem "4.30pm"
.AddItem "5pm"
.AddItem "5.30pm"
End With
With cboErectorsTime
.AddItem "7am"
.AddItem "7.30am"
.AddItem "8am"
.AddItem "8.30am"
.AddItem "9am"
.AddItem "10am"
.AddItem "10.30am"
.AddItem "11am"
.AddItem "11.30am"
.AddItem "12pm"
.AddItem "12.30pm"
.AddItem "1pm"
.AddItem "1.30pm"
.AddItem "2pm"
.AddItem "2.30pm"
.AddItem "3pm"
.AddItem "3.30pm"
.AddItem "4pm"
.AddItem "4.30pm"
.AddItem "5pm"
.AddItem "5.30pm"
End With
With cboPowerMetrestoSiteClientGeneratorwithFuel
.AddItem "Yes: Metres to site"
.AddItem "No: Take generator with client to supply unleaded fuel"
End With
With cboShedPositionPegged
.AddItem "--"
.AddItem "Client there"
End With
With cboTimbersPJNCLIENT
.AddItem "PJN"
.AddItem "Client"
End With
With cbocouncil
.AddItem "PJN"
.AddItem "Client"
End With
With cboconcrete
.AddItem "PJN"
.AddItem "Client"
End With
With cbobobcat
.AddItem "PJN"
.AddItem "Client"
End With
With cbocrane
.AddItem "PJN"
.AddItem "Client"
End With
With cbotruckaccess
.AddItem "Good"
End With
With cbositewet
.AddItem "Yes"
.AddItem "No"
End With
With cbohazard
.AddItem "Supplied"
End With
With cbost
.AddItem "7am"
.AddItem "7.30am"
.AddItem "8am"
.AddItem "8.30am"
.AddItem "9am"
.AddItem "10am"
.AddItem "10.30am"
.AddItem "11am"
.AddItem "11.30am"
.AddItem "12pm"
.AddItem "12.30pm"
.AddItem "1pm"
.AddItem "1.30pm"
.AddItem "2pm"
.AddItem "2.30pm"
.AddItem "3pm"
.AddItem "3.30pm"
.AddItem "4pm"
.AddItem "4.30pm"
.AddItem "5pm"
.AddItem "5.30pm"
End With
With cboPJNCLIENTSCISSOR
.AddItem "PJN"
.AddItem "Client"
End With
End Sub


Any comments would be greatly appreciated! Have a great day. :hi:

katenardy
02-24-2013, 03:03 PM
Sorry about the huge amount of information! I just looked again and might have overdid it with my original post! Please know that I have looked all over the internet with help on this, contacted IT people in our area - we are located in rural NSW, Australia, and I am happy to pay a consultant if I could find one - if anyone can refer me I'd appreciate it. This was my last resort, so again, thanks in advance.

gmaxey
02-24-2013, 06:50 PM
Katie,

What do you mean by "and I just cannot get the document to take the code with it?

Have you do you mean you copied the document from your PC on to your colleagues PC and when you open it there is no userform?

Have you tried replacing AutoOpen with Document_Open

Have your tried moving the AutoOpen code in ThisDocument to a new standard module?

katenardy
02-24-2013, 10:18 PM
Yes Greg that is what I meant, apologies for being unclear, being new I'm sure my terminology isn't very good.

Your solution worked, thank you very much, I've been tearing my hair out and haven't found anyone to read my code. Kindness of strangers indeed!:friends: