Teacher In Urgent Need of Help

Joined
Mar 17, 2015
Messages
11
Hi everyone,

Sorry, with vbna I am only at the search for what I want, find what I can alter and put the pieces together stage of vba i.e. quite a novice. Your help is MUCH appreciated as I am using excel to automatically update a form with every change of lesson to give links focus and time. Considering I will be teaching four subjects at secondary this is a need, not a want.

Image is at:
https://lh5.googleusercontent.com/l...4uZbAorfzxmXt70XdU7SZVYy9WmG09wyaFzu7mY=w1175


It was working perfectly and then all of a sudden I am getting:-

Run time error 4242 Object required, have also had File path error but will come to that later.

Is it simply that I have not declared data type or label1 as string?

Advise me please. Thx
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
It looks like you haven't granted access to the content at that link. Perhaps you could just post the code and tell us which line causes the error.
 
Upvote 0
Well all of the lines were working which is why it confuses me so. The first line on the sub is what is currently is in yellow (UserForm1.Label1.Caption = Worksheets("CurrentLesson").Range("C1").Value) but if I turn it into a message by adding a ' it just goes on to the next line with a cell reference.
Code:
Sub openform()
    
  
    
    UserForm1.Label1.Caption = Worksheets("CurrentLesson").Range("C1").Value
    
    UserForm1.Label2.Caption = ActiveSheet.Range("A1") & " you will be focused on " & ActiveSheet.Range("G1") & Chr$(13) & Chr$(13)
    UserForm1.Label3.Caption = "!Learning focus:- " & ActiveSheet.Range("E1")
    UserForm1.Label4.Caption = ActiveSheet.Range("A2") & " you were focused on " & ActiveSheet.Range("G2") & Chr$(13) & Chr$(13)
    UserForm1.Label5.Caption = "!Learning focus:- " & ActiveSheet.Range("E2")
    UserForm1.Label6.Caption = "Yesterday's comments:- " & ActiveSheet.Range("P2")
    
    UserForm1.Label7.Caption = "L" & ActiveSheet.Range("C1")
    UserForm1.Label9.Caption = "Good " & Worksheets("CurrentLesson").Range("L1") & Worksheets("CurrentLesson").Range("I1") & ".  Please get in and get on."
    UserForm1.Label10.Caption = "Today's exercise is " & ActiveSheet.Range("F1") & "."
    UserForm1.Show


End Sub
 
Last edited by a moderator:
Upvote 0
Are you sure there is still a form called UserForm1 in that workbook? The file/path error is often an indication of corruption, by the way.
 
Upvote 0
I can't access that link either.

What code do you have in the Userform_Initialize event and/or Userform_Activate event?
 
Upvote 0
Code:
Private Sub Image1_Link()
    Dim FilePath As String
    Dim ImageName As String
    Dim FullImagePath As String
    
    FilePath = "\\twgsb\shares\Common\0Bholden\Images"
    ImageName = "A.jpg"


    If ActiveSheet.Range("K1").Value <> "" Then
    ImageName = ActiveSheet.Range("K1").Value
    FullImagePath = FilePath & ImageName
    
    Image1.Picture = LoadPicture(FullImagePath)
    
    Else


    FullImagePath = "file:\\twgsb\shares\Common\0Bholden\Images\Blank.jpg"


    End If


  
    Image1.Visible = True
    Image1.Picture = LoadPicture(FullImagePath)
    


End Sub




Private Sub UserForm_Initialize()


Me.Label1 = Time


    'Application.OnTime Time + TimeValue("00:00:15"), "Live_time"


Image1_Link
End Sub






Private Sub UserForm_Terminate()
    'Application.OnTime Time + TimeValue("00:00:15"), "Live_time", , False
End Sub
Private Sub DateTime()
  DateTime.Caption = Worksheets("CurrentLesson").Range("C1").Value
End Sub








Private Sub CommandButton1_Click()
  Dim strFind As String


    strFind = ActiveSheet.Range("L1")


            
        ThisWorkbook.FollowHyperlink strFind
End Sub


Private Sub CommandButton3_Click()
  Dim strFind As String


    strFind = ActiveSheet.Range("O1")


            
        ThisWorkbook.FollowHyperlink strFind
End Sub




Private Sub CommandButton4_Click()
  Dim strFind As String


    strFind = ActiveSheet.Range("L2")


            
        ThisWorkbook.FollowHyperlink strFind
End Sub


Private Sub CommandButton5_Click()
  Dim strFind As String


    strFind = ActiveSheet.Range("O2")


            
        ThisWorkbook.FollowHyperlink strFind
End Sub


Private Sub CommandButton6_Click()
  Dim strFind As String


    strFind = ActiveSheet.Range("D2")


            
        ThisWorkbook.FollowHyperlink strFind
End Sub










Private Sub CommandButton7_Click()
Dim strFind As String


    strFind = "file:\\twgsb\shares\Common\0Bholden\PPT\Ninja\Series-A-Numeracy-Ninjas-Skill-Book-Answers-V5-Apr-2016.pptx"
            
        ThisWorkbook.FollowHyperlink strFind
End Sub


Private Sub CommandButton8_Click()
  Dim strFind As String


    strFind = ActiveSheet.Range("D1")


            
        ThisWorkbook.FollowHyperlink strFind
End Sub
 
Last edited by a moderator:
Upvote 0
In your VB Editor, click Tools - Options, then on the General tab, change the Error Trapping section to the 'Break in class module' option, then OK out and run the original code again. Which line is highlighted now when it errors?
 
Upvote 0
It sounds like you don't have an Image control on the form, or it's been renamed.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top