Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Teacher In Urgent Need of Help
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Mar 2015
    Location
    Kent, UK
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Teacher In Urgent Need of Help

    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/lO...yaFzu7mY=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

  2. #2
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,818
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    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.

  3. #3
    New Member
    Join Date
    Mar 2015
    Location
    Kent, UK
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    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 RoryA; Aug 20th, 2019 at 08:43 AM. Reason: Code tags

  4. #4
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,818
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    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.

  5. #5
    New Member
    Join Date
    Mar 2015
    Location
    Kent, UK
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    No I did not know that but all work is being done in school so I would be suprised.

    Here is the image of my form in design view. Cannot open it due to the error message.

    https://lh4.googleusercontent.com/3L...4I4tnEbUO=w673

  6. #6
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,818
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    I can't access that link either.

    What code do you have in the Userform_Initialize event and/or Userform_Activate event?

  7. #7
    New Member
    Join Date
    Mar 2015
    Location
    Kent, UK
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    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 RoryA; Aug 20th, 2019 at 09:25 AM. Reason: Code tags

  8. #8
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,818
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    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?

  9. #9
    New Member
    Join Date
    Mar 2015
    Location
    Kent, UK
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    Just to say thank you for your interest.

    Image1.Picture = LoadPicture(FullImagePath) ~goes yellow now

  10. #10
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,818
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Teacher In Urgent Need of Help

    It sounds like you don't have an Image control on the form, or it's been renamed.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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