Solved

Excel Code

Posted on 2006-11-15
4
278 Views
Last Modified: 2010-04-16
I am new with VBA and am trying to run this code in Excel 2003.  It is complaining about my Opt1, etc. handling.

here is the code.  Help please.

Private Sub CommandButton1_Click()

Dim binder As Object

If Opt1.Value = True Then
    binder.Text = "Audit"
End If

If Opt2.Value = True Then
    binder.Text = "Compilation"
End If

If Opt3.Value = True Then
    binder.Text = "Consulting"
End If

If Opt4.Value = True Then
    binder.Text = "Compilation"
End If

If Opt5.Value = True Then
    binder.Text = "TXR w/ PF"
End If

Workbooks.Add

    With ActiveSheet.PageSetup
        .LeftFooter = "Engagement\" & ClientName.Text & "\" & BinderYear.Text & "\" & binder.Text & Chr(10) & FileDesc.Text
        .CenterFooter = "&8&A"
        .RightFooter = "&8&D"
    End With
   
    Unload EngDocStmp2
   
End Sub
0
Comment
Question by:hckynt
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 17950804
What kind of control is Opt1-5? if it is a checkbox or radio button the syntax would be more like

If Opt1.Checked = True Then...
0
 

Author Comment

by:hckynt
ID: 17950851
Yes, they are check boxes and I have modified as suggested.  It is still complaining about  binder.Text = "Audit".  Is Dim binder as object sufficient to capture the text from the if statements?  Thanks.
0
 
LVL 17

Accepted Solution

by:
Daniel Reynolds earned 250 total points
ID: 17951116
If binder is just a variable for you, then implement as follows

dim binder

binder = "text here"

0
 

Author Comment

by:hckynt
ID: 17951136
Thanks for the help.  I decided to use a drop down instead and got it working.  Here is the code and you can have the points.

Private Sub UserForm_Activate()
    BinderType.AddItem "Audit"
    BinderType.AddItem "Compilation"
    BinderType.AddItem "Consulting"
    BinderType.AddItem "Compilation"
    BinderType.AddItem "TXR w/ PF"
End Sub

Private Sub CommandButton1_Click()

Workbooks.Add

    With ActiveSheet.PageSetup
        .LeftFooter = "Engagement\" & ClientName.Text & "\" & BinderYear.Text & "\" & BinderType.Text & "\" & Chr(10) & FileDesc.Text
        .CenterFooter = "&8&A"
        .RightFooter = "&8&D"
    End With
   
    Unload EngDocStmp2
    Unload EngDocStmp1
    Unload BAADocStmp
   
End Sub

Private Sub CommandButton2_Click()
    Unload EngDocStmp2
End Sub
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question