PDA

View Full Version : Combo Box within Word .DOC problem becoming a .DOT



andi
03-28-2008, 03:44 AM
Good Morning All,

I am having problems turning my Matter_Creation_Form.DOC into a Matter_Creation_Form.DOT.

Now,

Within Word, I have created a document that contains 2 Combo Boxes which, when a .DOC file, the contents of them appears fine.

I then resave the file as a template (with the extension .DOT to change it into a template) and the contents of the Combo Boxes does not appear.

Can you please advise me on where I am going wrong!

Please find my code below;

Now I know the code is very basic, but it works fine for me as a .doc, just not as a .dot! Do i need to insert anything in order to display the contents of the combo boxes within a .DOT successfully?


Private Sub Document_Open() 'When Matter Creation Form is Opened...
With ComboBox1
'Populate Combo box with...
.AddItem " use dropdown or refer to list at doc#201064 "
.AddItem " ---COMMERCIAL--- "
.AddItem "Shareholders Agreement "
.AddItem "LLP conversions "
.AddItem "LLP agreements "
.AddItem "Reorganisations "
.AddItem "Distribution Agreement "
.AddItem "Supply Agreement "
.AddItem "Terms & Conditions of Business "
.AddItem "Secondment "
.AddItem "General Commercial "
.AddItem " ---CORPORATE--- "
.AddItem "Share Purchase "
.AddItem "Share Sale "
.AddItem "Business Purchase "
.AddItem "Business Sale "
.AddItem "Business Recovery "
.AddItem "Banking "
.AddItem "Retail Pharmacy Sale "
.AddItem "Retail Pharmacy Purchase "
.AddItem "Dentist Purchase "
.AddItem "GP Surgery Purchase "
.AddItem " ---DISPUTE RESOLUTION--- "
.AddItem "Construction Disputes "
.AddItem "Supply of Goods & Services Disputes "
.AddItem "Purchase of Goods & Services Disputes "
.AddItem "Shareholder/Business Ownership Disputes "
.AddItem "General Commercial Contract Disputes "
.AddItem "Property Disputes "
.AddItem "Commercial Agency Disputes "
.AddItem "Judicial Review/Public Law "
.AddItem "Insolvency "
.AddItem "Contentious Intellectual Property "
.AddItem "Miscellaneous Litigation "
.AddItem " ---PROPERTY--- "
.AddItem "Commercial Lease - Landlord "
.AddItem "Commercial Lease - Tenant "
.AddItem "Commercial Lease - Licence to Assign "
.AddItem "Commercial - Purchase "
.AddItem "Commercial - Sale "
.AddItem "Commercial - Option "
.AddItem "Commercial - Development Agreement "
.AddItem "Commercial - Financing "
.AddItem "Commercial - Planning s.106 "
.AddItem "House Builder - Purchase "
.AddItem "House Builder - Sale "
.AddItem "House Builder - Plot Sales "
.AddItem "House Builder - Option "
.AddItem "House Builder - Development Agreement "
.AddItem "House Builder - Financing "
.AddItem "House Builder - Planning s.106 "
.AddItem "Public Sector - Purchase "
.AddItem "Public Sector - Sale "
.AddItem "Public Sector - Lease "
.AddItem "Public Sector - Secondment "
.AddItem "Public Sector - Planning s.106 "
.AddItem "Public Sector - Development Agreement "
.AddItem "Planning - Not s.106 "
.AddItem "Secured Lending "
.AddItem " ---TECHNOLOGY--- "
.AddItem "Software "
.AddItem "Trademarks "
.AddItem "Copyright "
.AddItem "Confidential Information "
.AddItem "Patents "
.AddItem "Design Rights "
.AddItem "Corporate Support "
.AddItem "Domain Names "
.AddItem "Media "
.AddItem "Data Protection "
.AddItem "e-Commerce "
.AddItem "Outsourcing "
.AddItem "Procurement "
.AddItem "Technology Agreements "
.AddItem "Dealing with the Press "
.ListIndex = 0
End With
With ComboBox2
'Populate Combo box with...
.AddItem " use dropdown or refer to list at doc#218397 "
.AddItem " --- A - AGRICULTURE, FORESTRY AND FISHING ---"
.AddItem " A01 - Crop and animal production, hunting and related service activities"
.AddItem " A02 - Forestry and logging"
.AddItem " A03 - Fishing and aquaculture"
.AddItem " --- B - MINING AND QUARRYING ---"
.AddItem " B08 - mining and quarrying"
.AddItem " B09 - Mining and quarrying support service activities"
.AddItem " --- C - MANUFACTURING ---"
.AddItem " C10 - Manufacture of food & beverage products"
.AddItem " C13 - Manufacture of textiles, clothing & leather"
.AddItem " C16 - Manufacture of wood, paper and related products"
.AddItem " C28 - Manufacture of machinery and equipment n.e.c."
.AddItem " C29 - Biotech & pharmaceutical"
.AddItem " C32 - Other manufacturing"
.AddItem " C33 - Repair and installation of machinery and equipment"
.AddItem " --- D - ELECTRICITY, GAS, STEAM AND AIR CONDITIONING SUPPLY ---"
.AddItem " D35 - Electricity, gas, steam and air conditioning supply"
.AddItem " --- E - WATER SUPPLY; SEWERAGE, WASTE MANAGEMENT AND REMEDIATION ACTIVITIES ---"
.AddItem " E36 - Water collection, treatment and supply (inc. sewerage)"
.AddItem " E38 - Waste collection activities"
.AddItem " E39 - Remediation activities and other waste management services"
.AddItem " E37 - Recycling & Materials Recovery (metal, paper, timber, plastic, special)"
.AddItem " E40 - Hazardous waste"
.AddItem " E44 - Waste treatment and disposal activities"
.AddItem " --- G - WHOLESALE AND RETAIL TRADE ---"
.AddItem " G46 - Wholesale trade"
.AddItem " G47 - Retail trade"
.AddItem " --- GG - MOTOR INDUSTRY ---"
.AddItem " GG41 - Supply and repair of commercial vehicles"
.AddItem " GG42 - Supply and repair of consumer vehicles"
.AddItem " --- H - TRANSPORTATION AND STORAGE ---"
.AddItem " H49 - Land transport and transport via pipelines (inc haulage and logistics)"
.AddItem " H50 - Water & air transport"
.AddItem " H52 - Warehousing and support activities for transportation"
.AddItem " --- I - ACCOMMODATION AND FOOD SERVICE ACTIVITIES ---"
.AddItem " I51 - Accommodation and food service activities (inc hotel and restaurant)"
.AddItem " --- J - INFORMATION AND COMMUNICATION ---"
.AddItem " J18 - Printing and reproduction of recorded media"
.AddItem " J58 - Publishing activities (other than music/sound)"
.AddItem " J59 - Motion picture, video and television programme production"
.AddItem " J60 - Programming and broadcasting activities"
.AddItem " J61 - Telecommunications"
.AddItem " J62 - Computer programming, consultancy and related activities"
.AddItem " J63 - Information service activities"
.AddItem " J52 - Internet/e-commerce activities"
.AddItem " J53 - Software publishing and distribution"
.AddItem " --- K - FINANCIAL AND INSURANCE ACTIVITIES ---"
.AddItem " K54 - Banking and financing activities"
.AddItem " K64 - Financial service activities, except insurance and pension funding"
.AddItem " K65 - Insurance, reinsurance and pension funding, except compulsory social security"
.AddItem " K66 - Activities auxiliary to financial service and insurance activities"
.AddItem " --- L - REAL ESTATE ACTIVITIES ---"
.AddItem " L68 - Real estate investment"
.AddItem " L55 - Housebuilders"
.AddItem " L56 - surveyors, estate agents"
.AddItem " L41 - Construction of buildings"
.AddItem " L42 - Civil engineering"
.AddItem " L43 - Specialized construction activities"
.AddItem " L57 - Building supplies"
.AddItem " --- M - PROFESSIONAL, SCIENTIFIC AND TECHNICAL ACTIVITIES ---"
.AddItem " M69 - Legal activities"
.AddItem " M05 - accounting activities"
.AddItem " M70 - Activities of head offices; management consultancy activities"
.AddItem " M71 - Architectural and engineering activities; technical testing and analysis"
.AddItem " M72 - Scientific research and development"
.AddItem " M73 - Advertising and market research"
.AddItem " M74 - Other professional, scientific and technical activities"
.AddItem " --- N - ADMINISTRATIVE AND SUPPORT SERVICE ACTIVITIES ---"
.AddItem " N77 - Rental and leasing activities"
.AddItem " N78 - Employment activities"
.AddItem " N79 - Travel agency, tour operator, reservation service and related activities"
.AddItem " N80 - Security and investigation activities"
.AddItem " N81 - Services to buildings and landscape activities"
.AddItem " N82 - Office administrative, office support and other business support activities"
.AddItem " --- O - PUBLIC ADMINISTRATION AND DEFENCE; COMPULSORY SOCIAL SECURITY ---"
.AddItem " O83 - Local authority"
.AddItem " O84 - Other public sector"
.AddItem " --- P - EDUCATION ---"
.AddItem " P85 - Education"
.AddItem " P86 - Childcare"
.AddItem " --- Q - HEALTHCARE ---"
.AddItem " Q87 - Residential care activities"
.AddItem " Q88 - Social work activities without accommodation"
.AddItem " Q75 - Veterinary activities"
.AddItem " Q06 - Dentistry activities"
.AddItem " Q07 - Retail Pharmacy activities"
.AddItem " Q11 - GP Surgeries"
.AddItem " --- R - ARTS, ENTERTAINMENT AND RECREATION ---"
.AddItem " R90 - Creative, arts and entertainment activities"
.AddItem " R91 - Libraries, archives, museums and other cultural activities"
.AddItem " R92 - Gambling and betting activities"
.AddItem " R93 - Sports activities and amusement and recreation activities"
.AddItem " --- S - OTHER SERVICE ACTIVITIES ---"
.AddItem " S94 - Activities of membership organizations"
.AddItem " S95 - Repair of computers and personal and household goods"
.AddItem " S96 - Other personal service activities"
.ListIndex = 0
End With
End Sub

Thank you for taking a look, any help will be gratefully recieved!
Kind Regards,

Andi

Edit Lucas: Andi, I added vba tags to your code. When posting code select it and hit the vba button.

lucas
03-28-2008, 07:44 AM
Not sure but try changing:

Private Sub Document_Open()
to:
Private Sub Document_New()

Then save it as a template. When you are using a template you want your code to fire when you create a new document.....not when you open the template.

fumei
03-29-2008, 10:37 PM
And you may want to rethink having so many items in the comboboxes.

andi
03-31-2008, 01:08 AM
Lucas, many thanks for your help. Worked brilliantly!

Fumei, what would you suggest I try to use instead of a Combo Box, as not sure what else I could use to display many items, one of which is selected by the user.

Regards,

Andi

fumei
03-31-2008, 11:35 AM
Use arrays, and either change the combobox itself, as in below:

ONE combobox with:

" ---COMMERCIAL--- "
" ---CORPORATE--- "
" ---DISPUTE RESOLUTION--- "
" ---PROPERTY--- "
" ---TECHNOLOGY--- "

Sub cboWhatever_Change()
Dim j As Long
Dim arrCommercial()
arrCommercial = Array("Shareholders Agreement ", "LLP conversions ", _
"LLP agreements ", "Reorganisations ", _
"Distribution Agreement ", "Supply Agreement ", _
"Terms & Conditions of Business " )
Select case cboWhatever.Text
Case " ---COMMERCIAL--- "
' i.e. Commerical selected
with cboWhatever
' clear the contents
.Clear
' repopulate
For j = 0 To Ubound(arrCommercial)
.AddItem arrCommercial(j)
Next
.ListIndex = 0
End With

' the other possibilities



So the combobox FIRST shows:

" ---COMMERCIAL--- "
" ---CORPORATE--- "
" ---DISPUTE RESOLUTION--- "
" ---PROPERTY--- "
" ---TECHNOLOGY--- "

and if Commercial is selected, it clears all the items, and repopulates with:

"Shareholders Agreement "
"LLP conversions "
"LLP agreements "
"Reorganisations "
"Distribution Agreement "
"Supply Agreement "
"Terms & Conditions of Business "

and so on, and so forth.

OR, you could populate a second combobox from the decision made in the first. Personally, I hate scrolling huge amounts in comboboxes.

fumei
03-31-2008, 11:39 AM
Instead of cboWhatever.Text (e.g. " ---COMMERCIAL--- " ) you could also use - and it may be better - the ListIndex number.

Select Case cboWhatever.ListIndex
Case 0 ' the same as " ---COMMERCIAL--- "



Also, you may want to consider using arrays, as EACH of your .AddItem instructions is an individually parsed instruction.

fumei
03-31-2008, 11:46 AM
Oh, I suppose I should mention that you would of course have to encorporate some logic into the changed items.

Say they select "Commercial" and the items change to "Shareholders Agreement "
"LLP conversions "

etc.

You will have to check - in the Change event itself - what array was used to populate. This is not difficult. Add a Public variable.

andi
04-01-2008, 01:24 AM
Fumei,


Many thanks,
I do not know an awful lot about programming just yet, but that seems a much more structured and organised way to list items, and easier for my end users.

Will have a go at your suggestions.

Again, thank you for your help.

Andi :o)

fumei
04-01-2008, 02:26 PM
"seems a much more structured and organised way to list items, and easier for my end users"

Both of those are the goal.