Solved

Excel Code

Posted on 2006-11-15
4
273 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:xDJR1875
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:
xDJR1875 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bigHeights  challenge 13 59
Fibonacci challenge 11 108
stringclean challenge 26 70
oracle query help 18 99
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now