Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2017, 09:57 AM
aramaglia aramaglia is offline Assigning Form.ActiveControl.Name to variable Windows 7 64bit Assigning Form.ActiveControl.Name to variable Office 2016
Novice
Assigning Form.ActiveControl.Name to variable
 
Join Date: Jan 2017
Posts: 8
aramaglia is on a distinguished road
Question Assigning Form.ActiveControl.Name to variable

Hello,



I have this worksheet that when macro is run, a userform will pop up and allow the user to select from a few choices (using commandbuttons), which will then update a bunch of pivot charts and tables based on that buttons tags and activecontrol.name. The code works great. I am now trying to update this with a code that will tell if a specific workbook is open, and if so, then assign the tags and activcecontrol.name based on that user's system username. I am able to assign the userform tag, but I get a "'Run-time error '91': Object variable or With Block variable not set" error when trying to assign the activecontrol.name. I have been unable to find out if this is even possible, and hoping someone can give me some pointers. Below is the relevant code:

Code:
'Main Module
Option Compare Text

Public OEETag As String
Public OEEActiveControl As String

Public Sub OEE4Q()

Dim Ret As Boolean
Dim myForm1 As FilterOEE

Set myForm1 = New FilterOEE

Ret = IsWorkBookOpen("G:\Shared\MOS TBO\OEE\OEE- 4Q1.xlsm")

    If Ret = True Then
        SupervisorDept
        myForm1.Tag = OEETag
        Set myForm1.ActiveControl = OEEActiveControl '<--- Error occurs here
        GoTo SuperRepGen
    End If
    
    myForm1.Show

SuperRepGen:
    
    Select Case myForm1.Tag

'Rest of Code

End sub
---------------------------------------------------------
'sub which assigns tag and activecontrol.name based on username
Sub SupervisorDept()

    Debug.Print Username
    If Username = "aramaglia" Then
        OEETag = "ASY_FIQD"
        OEEActiveControl = "FIQD"
    End If
    
End Sub
---------------------------------------------------------
'Functions
Public Function Username()

    Username = Environ$("UserName")
    
End Function

Function IsWorkBookOpen(FileName As String)
    Dim ff As Long, ErrNo As Long

    On Error Resume Next
    ff = FreeFile()
    Open FileName For Input Lock Read As #ff
    Close ff
    ErrNo = Err
    On Error GoTo 0

    Select Case ErrNo
    Case 0:    IsWorkBookOpen = False
    Case 70:   IsWorkBookOpen = True
    Case Else: Error ErrNo
    End Select
End Function
Reply With Quote
Reply

Tags
activecontrol, userforms, variable



Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Variable or With block variable not set Raza Excel Programming 8 01-15-2015 12:19 AM
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge Berryblue Mail Merge 1 11-13-2014 05:36 PM
Assigning Form.ActiveControl.Name to variable Run-time error 91 object variable or with block variable not set JUST ME Word VBA 4 03-25-2014 06:56 AM
Assigning Form.ActiveControl.Name to variable object variable or with block variable not set MJP143 Excel 1 02-11-2013 05:07 AM
Assigning Form.ActiveControl.Name to variable Run-time error '91': Object variable or With block variable not set tinfanide Excel Programming 2 06-10-2012 10:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft