Results 1 to 19 of 19

Thread: Run-time error '445' - Object doesn't support this activity

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #14
    Thank you so much, snb!


    I am no longer getting a run-time error and the macro is invoking the drop-down menu that will allow the user to select one of the style sheet files in the directory. I also commented out the Unload UserForms line. I kept receiving another run-time error, 438 "Object doesn't support this property or method".


    Sub OpenStyleSheets()
    ‘Unload UserForms.StyleTypes
    StyleTypes.Show
    End Sub


    I also added the StyleTypes.Show line. I believe the previous code had UserForms.Show because the style sheets were not being displayed in the drop-down.


    Private Sub UserForm_Initialize()
    GetStyleTypes
    StyleTypes.Show
    End Sub


    I am not experiencing an issue with closing the user form (style sheet) after one has been selected. I am researching the code for the UserForms.Hide line.

    I've attached a couple of screenshots for reference.


    Best regards,
    SOJ

    Quote Originally Posted by snb View Post
    This will solve your problem:

    Sub GetStyleTypes() 
        Dim Dirlen As Integer 
        Dim f, f1, fc, s 
        Dim iFileCount As Integer 
        Dim strTemp As String 
        iFileCount = 0 
        GetDirectory 
    '    Set fs = Application.FileSearch 
    '   With fs 
    '        .LookIn = Directory 
    '        .FileType = msoFileTypeExcelWorkbooks 
    '        If .Execute > 0 Then 
    '            iFileCount = .FoundFiles.Count 
    '            For i = 1 To iFileCount 
    '                Dirlen = Len(.LookIn) + 2 
    '                strTemp = Mid(.FoundFiles(i), Dirlen) 
    '                StyleBox.AddItem (strTemp) 
    '            Next i 
    '        End If 
    '    End With 
    '    If iFileCount = 0 Then 
    '        Set fs = Nothing 
            Set fs = CreateObject("Scripting.FileSystemObject") 
            Set f = fs.GetFolder(Directory) 
            Set fc = f.Files 
            For Each f1 In fc 
                If UCase(Right((f1.Name), 4)) = ".XLS" Then 
                    iFileCount = iFileCount + 1 
                    Dirlen = Len(Directory) + 2 
                    strTemp = f1.Name 
                    StyleBox.AddItem (strTemp) 
                End If 
            Next 
    '    End If 
    cleanup: 
        Set fs = Nothing 
        Set f = Nothing 
        Set fc = Nothing 
    End Sub
    Attached Images Attached Images

Tags for this Thread

Posting Permissions

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