+ Reply to Thread
Results 1 to 4 of 4

Compile Error: Variable not defined. (Excel 2007)

  1. #1
    Registered User
    Join Date
    03-12-2015
    Location
    Ottawa, Canada
    MS-Off Ver
    2007
    Posts
    3

    Compile Error: Variable not defined. (Excel 2007)

    Hi there, I've come across a most frustrating issue recently (using Excel 2007) regarding named ActiveX controls that reside on a Worksheet. Everything compiles and runs perfectly on my PC (Windows 7 32-bit/Office 2007) The file(s) in question are .XLS files, and when opened on another PC (Windows 7/Office 2007) as soon as the macros are enabled, it immediately opens the VBA code window up with one of my control names highlighted (e.g. "txtLName1") and shows the error message "Compile error - Variable Not Defined."

    I have hunted and hunted for potential solutions, but none that I found worked for me...does ~anybody~ here have any idea how I can fix this? Any help whatsoever would be greatly appreciated!!

    Procedure Code:
    Public Sub InitBackDoorControls()

    txtLName1.Visible = True ' Where highlight appears in context of error message
    txtLName1.Text = ""

    txtFName1.Visible = True
    txtFName1.Text = ""

    cbxPlan.Visible = True
    Call ShowPlanList

    chkFrzOnly.Visible = True
    chkFrzOnly.Value = False

    cbxFullOrSplit.Visible = True
    Call ShowFullOrSplitList

    lblPart.Caption = 1

    cbxNumDeliveries.Visible = True
    Call ShowNumDeliveriesList

    cbxHasCP.Visible = True
    Call ShowHasCPList

    txtLName1.Activate

    Range("COST_RATE") = ""
    COST_RATE = DEFAULT_COST_RATE

    cmdLoadFromFile.Visible = False

    End Sub

    The issue appears to be the fact that somehow, on a PC other than the one I am working on (where everything works just fine), the names of the ActiveX controls which reside on the Worksheet are being reset to default names i.e. "CommandButton1", "TextBox1" etc...and in that light, the code referencing the control by it's assigned name will trigger the error "Variable not defined." The "Option Explicit" statement seems to make no difference whatsoever.

    I have tried deleting *.exd files from %Temp% directories on client PCs...as suggested by Microsoft, and still to no avail!!!

    If you need more info from me, please advise...

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Compile Error: Variable not defined. (Excel 2007)

    Hi david,

    See if this site helps

    http://support.microsoft.com/en-us/kb/3025036
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-12-2015
    Location
    Ottawa, Canada
    MS-Off Ver
    2007
    Posts
    3

    Re: Compile Error: Variable not defined. (Excel 2007)

    Thankyou Marvin...checking in to this now...will try the FixIt solutions etc suggested by MS, and will post the outcome. <Fingers Crossed!>

  4. #4
    Registered User
    Join Date
    03-12-2015
    Location
    Ottawa, Canada
    MS-Off Ver
    2007
    Posts
    3

    Re: Compile Error: Variable not defined. (Excel 2007)

    SUCCESS!! Thanks again to MarvinP for a proper nudge in the right direction!

    In a nutshell, the nature of this issue had everything to do with the fact that the PC I was modifying the Workbook(s) in question on HAD all of the most recent MS Office Updates...where the Client PC's had not been set to download updates.

    After getting all the updates in order, I ran the Microsoft FixIt tool (found on the site suggested by MarvinP) and all is well in the world again.

    What a headache...but now...what a relief this issue is SOLVED!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compile error: Variable not defined
    By jrpuig1977 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-16-2014, 06:55 PM
  2. Compile error: variable not defined
    By jwoodman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2014, 06:52 AM
  3. Compile Error Variable not defined - VBA script MS Excel 2010
    By aoberoi83 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-02-2013, 08:57 PM
  4. [SOLVED] Compile Error: Variable Not Defined
    By Limitedtimeonearth in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-03-2013, 03:07 PM
  5. Compile error: Variable not defined
    By radion in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2007, 05:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1