Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel Code

Posted on 2006-11-15
4
Medium Priority
?
286 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 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

783 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