To Continue Typing Code Onto Another Line

  • Dear All,


    I am very new to VBA coding, but will be doing alot over the coming months, so I will probably become quite a regular for your expert help!


    Please bare with me if this is a really obvious, easy to solve problem.


    Within Word, I have created a Form that has a Combo Box.


    I have then gone into Design Mode and the combo box successfully so far.


    The problem is I am having is, as I have so many entries I wish to have in the Combo Box I have reached the end of the line and I am unable to type anymore on that line. I have tried dropping down a line and continued typing with the speech marks, but that just returns errors.


    If it helps, my Code is;


    [vba]
    Private Sub Document_Open()
    Dim vWorkType, vWorkTypes
    vWorkTypes = Array(" ", "Commercial Lease - Landlord", "Commercial Lease - Tenant", "Commercial Lease - Licence to Assign", "Commercial - Purchase", "Commercial - Sale", "Commercial - Option", "Commercial - Development Agreement", "Commercial - Financing", "Commercial - Planning S106", "House Builder - Purchase", "House Builder - Sale", "House Builder - Plot Sales", "House Builder - Option", "House Builder - Development Agreement", "House Builder - Financing", "House Builder - Planning S106", "Local Authority - Purchase", "Local Authority - Sale", "Local Authority - Lease", "Local Authority - Secondment", "Local Authority - Planning S106", "Development Agreement", "Planning - Other", "Secured Lending", "Shareholders Agreeements", "LLP Conversions", "LLP Agreements", "Reorganisations", "Distribution Agreement", "Supply Agreement", "Terms & Conditions of Business", "Secondment", "General Commercial", "Software", "Trademarks", "Copyright", "Confidential Information", "Patents", "Design Rights")


    For Each vWorkType In vWorkTypes
    ComboBox1.AddItem vWorkType
    Next
    ComboBox1.ListIndex = 0
    End Sub


    [/vba]
    All I want to do is add more items to my Combo Box, please help!


    In advance, thank you for your help,


    Any Feedback, help or suggestions will be very useful.


    Kind Regards,


    Andi

  • Re: To Continue Typing Code Onto Another Line


    Use line continutation character.


    [vba]
    Dim vWorkType, vWorkTypes


    vWorkTypes = Array(" ", "Commercial Lease - Landlord", "Commercial Lease - Tenant", "Commercial Lease - Licence to Assign", _
    "Commercial - Purchase", "Commercial - Sale", "Commercial - Option", "Commercial - Development Agreement", _
    "Commercial - Financing", "Commercial - Planning S106", "House Builder - Purchase", "House Builder - Sale", _
    "House Builder - Plot Sales", "House Builder - Option", "House Builder - Development Agreement", _
    "House Builder - Financing", "House Builder - Planning S106", "Local Authority - Purchase", _
    "Local Authority - Sale", "Local Authority - Lease", "Local Authority - Secondment", _
    "Local Authority - Planning S106", "Development Agreement", "Planning - Other", "Secured Lending", _
    "Shareholders Agreeements", "LLP Conversions", "LLP Agreements", "Reorganisations", "Distribution Agreement", _
    "Supply Agreement", "Terms & Conditions of Business", "Secondment", "General Commercial", "Software", _
    "Trademarks", "Copyright", "Confidential Information", "Patents", "Design Rights")


    For Each vWorkType In vWorkTypes
    ComboBox1.AddItem vWorkType
    Next
    ComboBox1.ListIndex = 0
    [/vba]


    Although even this will reach a limit.



    Don't forget to use code tags when posting code examples

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!