Solved

Excel Code

Posted on 2006-11-15
4
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …

752 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