Solved

Excel Code

Posted on 2006-11-15
4
266 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi Mdi application Child forms get behind control 7 112
mergeTwo  challenge 13 72
move one pixel 4 41
Path to Python 9 42
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will show, step by step, how to integrate R code into a R Sweave document
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 …
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 …

705 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

18 Experts available now in Live!

Get 1:1 Help Now