Filling out data on form from dropdown boxes & document lockdown

E

Eric Burkholder

I have two questions. First I am creating a document for bid specifications
for a piece of equipment. I have the document filled out and have several
user input points. Some of the data points I want to have only my company
fill out while having a vendor fill out the remaining. Is this possible?

Second I have two dropdown points
bkFacility - has 14 plant locations ex Burlington, WI, Dolton, IL, etc..
Upon selecting the facility name I want aset of lines for the address. I was
trying to do this in a Select Case. I have had no luck. Currently the
document displays "Error! No document variable supplied. There are three
variables vStreetAddress, vCityState & vPlantEng. Code below:

Sub Address()
Dim strStreetAddress As String
Dim strCityState As String
Dim strPlantEng As String
Dim oVars As Word.Variables
Set oVars = ActiveDocument.Variables
'
Select Case bkFacility.Value
Case "Burlington, WI"
strStreetAddress = "815 S. McHenry Street"
strCityState = "Burlington, WI 53105"
strPlantEng = "George Koontz"
Case "Dolton, IL"
strStreetAddress = "13850 Cottage Groove Ave."
strCityState = "Dolton, IL 60419"
strPlantEng = "Ed Sayers"
End Select
oVars("vStreetAddress").Value = strStreetAddress
oVars("vCItyState").Value = strCityState
oVars("vPlantEng").Value = strPlantEng
Set oVars = Nothing

End Sub

Second dropdown bkPressure lets user select either 75 or 100. Based on this
it will set three other variables vLoPressure, vMidPressure & vHiPressure at
determined values. Code below:

Sub Pressure()
Dim strLoPressure As String
Dim strMidPressure As String
Dim strHiPressure As String
Dim oVars As Word.Variables
Set oVars = ActiveDocument.Variables
'
Select Case bkPressure
Case "75"
strLoPressure = 55
strMidPressure = 65
strHiPressure = 75
Case "100"
strLoPressure = 80
strMidPressure = 90
strHiPressure = 100
End Select
oVars("vLoPressure").Value = strLoPressure
oVars("vMidPressure").Value = strMidPressure
oVars("vHiPressure").Value = strHiPressure
Set oVars = Nothing

End Sub
 
G

Graham Mayor

In both your macros you refer to variables that the macros know nothing
about ie bkFacility and bkPressure. You will need to define what these
variables are before you can use their values.

On the basis of the information provided, you probably need something like
the following, and if you are using docvariable fields to reproduce the
data, then if the document is a form, as appears to be the case, you will
need to update those fields to reflect the information read from the
dropdown.

Sub Address()
Dim strStreetAddress As String
Dim strCityState As String
Dim strPlantEng As String
Dim bkFacility As FormField
Dim oVars As Word.Variables
Set oVars = ActiveDocument.Variables
Set bkFacility = ActiveDocument.FormFields("bkFacility")
Select Case bkFacility.Result
Case "Burlington, WI"
strStreetAddress = "815 S. McHenry Street"
strCityState = "Burlington, WI 53105"
strPlantEng = "George Koontz"
Case "Dolton, IL"
strStreetAddress = "13850 Cottage Groove Ave."
strCityState = "Dolton, IL 60419"
strPlantEng = "Ed Sayers"
End Select
oVars("vStreetAddress").Value = strStreetAddress
oVars("vCItyState").Value = strCityState
oVars("vPlantEng").Value = strPlantEng
Set oVars = Nothing
'Update the docvariable fields
For i = 1 To ActiveDocument.Fields.Count
If ActiveDocument.Fields(i).Type = wdFieldDocVariable Then
ActiveDocument.Fields(i).Update
End If
Next i
End Sub

See http://www.gmayor.com/SelectFile.htm for some ideas.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

Eric Burkholder

The routines are now working thanks for the assistance.

The first part of the question remains about how to lock down a portion of
the form for my company to fill out while allowing the rest of the form to be
filled out by the vendor.
 
G

Graham Mayor

Who will be filling out the form first, your company or the vendor?

Thoughts that immediately spring to mind are:

If it is your company then you could run a macro to unlock the form convert
your completed fields to text then relock it. The vendor would then have no
simple way of accessing the fields - however it should be noted that any
document you allow someone to see is ultimately vulnerable to editing.

If it is the vendor then I guess I would not add the fields to your part of
the form until it is time for you to add to it, effectively revesing the
process. You could put bookmarks in the places where the fields go, then
insert the fields at the bookmarked locations when you receive the form,
having first converted the vendor filled fields to text.

From the information provided, that's the best I can come up with on the
spur of the moment :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

Eric Burkholder

We are filling out the form first. The areas we are filling out include the
dropdown and select case that you helped get working. Once that is complete
I want to be able to send the document to the vendor and they can either
print or fill out the remining fields. Thanks
 
G

Graham Mayor

Continuing the scenario I suggested earlier. The following macro will
convert all the named form fields in the case statements to text (checkbox
fields return 0 or 1 so I have substituted 16 point Wingdings
unchecked/checked boxes for those) leaving the remaining fields available
for the vendor to complete. As your filled fields no longer exist, the
vendor has no access to them.
Change the names in the case statrements to match the names of the fields
you want to fix.

Dim oFld As FormFields
Dim sText As String
Dim sName As String
Dim sFont As String
Dim sSize As Integer
Dim bProtected As Boolean
Set oFld = ActiveDocument.FormFields
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
For i = oFld.Count To 1 Step -1
sName = oFld(i).name
Select Case sName
Case Is = "Text1", "Text2", "Dropdown1" 'text and dropdowns
sText = oFld(i).Result
oFld(i).Select
Selection.Delete
Selection.TypeText sText
Case Is = "Check1", "Check2" 'check boxes
sText = oFld(i).Result
If sText = 1 Then
sText = Chr(254)
Else
sText = Chr(253)
End If
oFld(i).Select
With Selection
.Delete
sFont = .Font.name
sSize = .Font.Size
.Font.name = "Wingdings"
.Font.Size = 16
.TypeText sText
.Font.name = sFont
.Font.Size = sSize
End With
Case Else 'not named - ignore
End Select
Next i
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

On further reflection

If sText = 1 Then
sText = Chr(253)
Else
sText = Chr(111)
End If

would more closely resemble the original entry for check boxes.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

Eric Burkholder

Thank You for the help. I will give it a try.

Graham Mayor said:
On further reflection

If sText = 1 Then
sText = Chr(253)
Else
sText = Chr(111)
End If

would more closely resemble the original entry for check boxes.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top