Consulting

Results 1 to 19 of 19

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

  1. #1

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

    Hello Community,

    We are experiencing an issue with a delivered PeopleSoft nVision StyleSheets macro that was probably carried over from Excel 2003 or earlier. Our nVision environment is now using Excel 2007. However, many users have Excel 2010 or 2016 installed on their computers.

    The StyleSheeets macro is used to format PS nVision layouts (an Excel file). The StyleSheets templates are saved under a specific directory that is identified in the configuration for nVision in the PeopleSoft Application Designer program.


    I have a very limited understanding of VBA and would greatly appreciate some guidance.

    The run-time error 445 is first generated when the macro to Open Style Sheets is selected. When debug is selected, the "Unload StyleTypes" line is highlighted -
    Activates the Style Sheet creation wizard
    Sub OpenStyleSheets()
    Unload StyleTypes
    StyleTypes.Show
    End Sub
    After additional research, it was discovered that FileSearch is usually the cause of this run-time error. When the code was searched for FileSearch, the following code was found -

    ' Retrieves all valid Style sheets.
    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
    Last edited by Aussiebear; 05-10-2016 at 11:33 PM. Reason: Added hash tags to code

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    Hello sollijones,

    The VBA statement Unload is used to remove a VBA UserForm from memory. If the UserForm does not exist in memory then an error is thrown. You can easily remedy the situation by trapping and ignoring the error like this...

    Sub OpenStyleSheets()
        On Error Resume Next
             Unload StyleTypes
        On Error Goto 0
        StyleTypes.Show
    End Sub

    Sincerely,
    Leith Ross

    "1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"

  3. #3
    Thank you so much for your response, Leith.

    I updated the code based on your suggestion and now it errors on the StyleTypes.Show line.


    Quote Originally Posted by Leith Ross View Post
    Hello sollijones,

    The VBA statement Unload is used to remove a VBA UserForm from memory. If the UserForm does not exist in memory then an error is thrown. You can easily remedy the situation by trapping and ignoring the error like this...

    Sub OpenStyleSheets()
        On Error Resume Next
             Unload StyleTypes
        On Error Goto 0
        StyleTypes.Show
    End Sub


  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    I am probably just being goofy. If you highlight StyleTypes, right-click and select Definition, what happens?

  5. #5
    GTO, I received the following message:
    "Cannot jump to 'Show' because it is hidden."

    Quote Originally Posted by GTO View Post
    I am probably just being goofy. If you highlight StyleTypes, right-click and select Definition, what happens?

  6. #6
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Did the Object Browser Window pop-up? Right-click in the Members pane and select "Show Hidden Members". Now try it.

  7. #7
    GTO, the Object Browser Window did pop-up and I selected "Show Hidden Members". When I attempted to run the macro again, I received the following message:
    "Cannot jump to 'Show' because it is in the library 'Unknown7' which is not currently referenced". Please see the attached screenshot.

    Regards,
    SOJ

    Quote Originally Posted by GTO View Post
    Did the Object Browser Window pop-up? Right-click in the Members pane and select "Show Hidden Members". Now try it.
    Attached Images Attached Images

  8. #8
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Okay, thank you for testing. I do not think it (StyleTypes) is a userform. I am logging out shortly, but would it be possible to upload the workbook with the code in it? Scrub any sensitive data of course...

  9. #9
    GTO, thank you so much for assisting me with this. It seems that the 'Show' object should be moved to another library - either the one for the specific workbook (nvsuser.xls) or perhaps under MSForms. Please see the attached workbook.

    Best regards,
    SOJ

    Quote Originally Posted by GTO View Post
    Okay, thank you for testing. I do not think it (StyleTypes) is a userform. I am logging out shortly, but would it be possible to upload the workbook with the code in it? Scrub any sensitive data of course...
    Attached Files Attached Files

  10. #10
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    "Show" is not an object, it is a method. This is what the first sub in your first post is saying
    Sub OpenStyleSheets() 
        Unload UserForms("StyleTypes") 
        UserForms("StyleTypes").Show 
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  11. #11
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by GTO View Post
    Okay, thank you for testing. I do not think it (StyleTypes) is a userform. I am logging out shortly, but would it be possible to upload the workbook with the code in it? Scrub any sensitive data of course...
    ACK! I was wrong; it is a userform. See below...

    Quote Originally Posted by sollijones View Post
    Hello Community,

    We are experiencing an issue with a delivered PeopleSoft nVision StyleSheets macro that was probably carried over from Excel 2003 or earlier. Our nVision environment is now using Excel 2007. However, many users have Excel 2010 or 2016 installed on their computers.

    The StyleSheeets macro is used to format PS nVision layouts (an Excel file). The StyleSheets templates are saved under a specific directory that is identified in the configuration for nVision in the PeopleSoft Application Designer program.


    I have a very limited understanding of VBA and would greatly appreciate some guidance.

    The run-time error 445 is first generated when the macro to Open Style Sheets is selected. When debug is selected, the "Unload StyleTypes" line is highlighted -
    Activates the Style Sheet creation wizard
    ...

    After additional research, it was discovered that FileSearch is usually the cause of this run-time error. When the code was searched for FileSearch, the following code was found
    Although it appears expired, I did note this in the workbook: '* Copyright (c) 1988-1999 PeopleSoft, Inc. All Rights Reserved. *

    You mention that you are now using Excel2007, with some using newer versions than this. I believe that FileSearch was depreciated (a fancy way of saying it no longer works) in 2007 and thereafter. I would contact the vendor or PeopleSoft for a newer version of this workbook. I would be confident that they have long since updated the workbook to use another method.

    Sorry for missing what you clearly stated in your first post...

    Mark

  12. #12
    Thank you for taking the time to look into this. Yes, I was informed that FileSearch no longer worked in 2007. However, since the code didn't error on that I wasn't convinced that that was the root of the problem. Unfortunately, we are no longer under Oracle support. I've been researching how to update the FileSearch code to be applicable to newer versions of Excel.

    Best regards,
    SOJ

    Quote Originally Posted by GTO View Post
    ACK! I was wrong; it is a userform. See below...



    Although it appears expired, I did note this in the workbook: '* Copyright (c) 1988-1999 PeopleSoft, Inc. All Rights Reserved. *

    You mention that you are now using Excel2007, with some using newer versions than this. I believe that FileSearch was depreciated (a fancy way of saying it no longer works) in 2007 and thereafter. I would contact the vendor or PeopleSoft for a newer version of this workbook. I would be confident that they have long since updated the workbook to use another method.

    Sorry for missing what you clearly stated in your first post...

    Mark

  13. #13
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    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

  14. #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

  15. #15
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    This is awful

    Private Sub UserForm_Initialize()
                GetStyleTypes
                StyleTypes.Show
    End Sub
    it should read

    Private Sub UserForm_Initialize()
      GetStyleTypes
                End Sub

  16. #16
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    much easier/faster to accomplish with :

    Sub Userform_initialize() 
      with CreateObject("Scripting.FileSystemObject")
        for each it in .GetFolder(Directory).Files 
           If ucase(.getextensionname(it)) = "XLS" Then c00=c00 & "|" &it.name
        Next
     
        StyleBox.list=split(mid(c00,2),"|")
      end with
    End Sub

  17. #17
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Kensington in Eastern hemisphere!!

  18. #18

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

    Thanks. Actually, the code didn't work until I added the "StyleTypes.Show" line.

    The macro is now working as intended. Thank you for all of your assistance.

    Regards,
    SOJ

    Quote Originally Posted by snb View Post
    This is awful

    Private Sub UserForm_Initialize()
                GetStyleTypes
                StyleTypes.Show
    End Sub
    it should read

    Private Sub UserForm_Initialize()
      GetStyleTypes
                End Sub

  19. #19

    More FileSearch issues

    Another newb trying to figure out a workaround for filesearch.

    I'm not a
    VBA guy, I have recorded Macros and such in the past and edited some VBA code before but this is killing me. My site just updated their MS products to 2013 and this was written for 2003 so the Filesearch option doesn't work. I know this needs to be updated but I have NO idea how.

    Here is the code:

    With Application.FileSearch
            .LookIn = p
            .Filename = "*.*"
            If .Execute() > 0 Then
                For i = 1 To .FoundFiles.Count
                    NumberofRuns = .FoundFiles.Count
                    Filename = .FoundFiles(i)
                    
                    Sheets("GM Template").Copy After:=Sheets(i + 2 + k)
                    Sheets("GM Template (2)").Name = "GM Table " & i
                    Sheets("S&H Template").Copy After:=Sheets(i + 3 + k)
                    Sheets("S&H Template (2)").Name = "S&H Run " & i
                    
                    Workbooks.OpenText Filename:=Filename _
                        , Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
                        :=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _
                        False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
                    MyReport = ActiveWorkbook.Name
                    Range("A1").Select
                    Selection.End(xlDown).Select
                    RowEnd = ActiveCell.Row
                    Range("A1").Select
                    Selection.End(xlToRight).Select
                    ColumnEnd = ActiveCell.Column
                    Range(Cells(1, 1), Cells(RowEnd, ColumnEnd)).Select
                    Cells.Select
                    Selection.Sort Key1:=Range(SearchColumn), Order1:=xlAscending, Key2:=Range("A2") _
                        , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
                        , Orientation:=xlTopToBottom
                    Range(Cells(1, 1), Cells(RowEnd, ColumnEnd)).Copy
                    Windows(MyBook).Activate
                    Sheets("GM Table " & i).Select
                    Range("A1").Select
                    ActiveSheet.Paste
                    
                    Windows(MyReport).Activate
                    Application.DisplayAlerts = False
                    ActiveWorkbook.Close
                
                    If DyeSet = "DS33" Then
                        Call DS33
                    ElseIf DyeSet = "DS30" Then
                        Call DS30
                    ElseIf DyeSet = "Identifiler" Then
                        Call Identifiler
                    ElseIf DyeSet = "ProPlus" Then
                        Call ProPlus
                    ElseIf DyeSet = "SNaPshot" Then
                        Call SNaPshot
                    ElseIf DyeSet = "ALFP" Then
                        Call ALFP
                    End If
                    
                    k = k + 1
                    
                    Sheets("S&H Summary").Select
                    Range("B4").Select
                    If ActiveCell.Value <> False Then
                        Selection.End(xlToRight).Select
                        ColumnTracker = ActiveCell.Column
                        PasteColumn = ColumnTracker + 1
                    Else
                        PasteColumn = 2
                    End If
                    
                    Sheets("S&H Run " & i).Select
                    Range("B2:C34").Copy
                    Sheets("S&H Summary").Select
                    Cells(4, PasteColumn).Select
                    Selection.PasteSpecial Paste:=xlValues
                    Selection.NumberFormat = "0.00"
                    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
                    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                    With Selection.Borders(xlEdgeLeft)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlEdgeTop)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlEdgeBottom)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlEdgeRight)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlInsideVertical)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlInsideHorizontal)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    Cells(3, PasteColumn).Value = "Run " & i
                    
                    If CapFlag <> 0 Then
                        Cells(2, PasteColumn).Select
                        With Selection.Interior
                            .ColorIndex = 6
                            .Pattern = xlSolid
                        End With
                        Cells(2, PasteColumn).Value = CapFlag
                    ElseIf MissingFlag <> 0 Then
                        Cells(1, PasteColumn).Select
                        With Selection.Interior
                            .ColorIndex = 46
                            .Pattern = xlSolid
                        End With
                        Cells(1, PasteColumn).Value = MissingFlag
                    End If
                    
                    For j = 5 To 5 + UBound(Alleles)
                        Cells(j, PasteColumn + 1).Select
                        If IsNumeric(ActiveCell.Value) = False Then
                            Range(Cells(j, PasteColumn), Cells(j, PasteColumn + 1)).Select
                            Selection.ClearContents
                            With Selection.Interior
                                .ColorIndex = 3
                                .Pattern = xlSolid
                            End With
                        ElseIf ActiveCell.Value >= Precision Then
                            With Selection.Interior
                                .ColorIndex = 3
                                .Pattern = xlSolid
                            End With
                        End If
                    Next j
                    
                    Sheets("S&H Run " & i).Select
                    Range("D2:E34").Copy
                    Sheets("S&H Summary").Select
                    Cells(39, PasteColumn).Select
                    Selection.PasteSpecial Paste:=xlValues
                    Selection.NumberFormat = "0.0"
                    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
                    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                    With Selection.Borders(xlEdgeLeft)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlEdgeTop)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlEdgeBottom)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlEdgeRight)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlInsideVertical)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    With Selection.Borders(xlInsideHorizontal)
                        .LineStyle = xlContinuous
                        .Weight = xlThin
                        .ColorIndex = xlAutomatic
                    End With
                    Cells(38, PasteColumn).Value = "Run " & i
                    
                    For j = 40 To 40 + UBound(Alleles)
                        Cells(j, PasteColumn).Select
                        If IsNumeric(ActiveCell.Value) = False Then
                            Range(Cells(j, PasteColumn), Cells(j, PasteColumn + 1)).Select
                            Selection.ClearContents
                            With Selection.Interior
                                .ColorIndex = 3
                                .Pattern = xlSolid
                            End With
                        ElseIf ActiveCell.Value <= 150 And ActiveCell.Value <> "" And DyeSet <> "ALFP" Then
                            With Selection.Interior
                                .ColorIndex = 3
                                .Pattern = xlSolid
                            End With
                        End If
                    Next j
                    
                    Cells(73, PasteColumn).Value = MyReport
                    
                Next i
            Else
                MsgBox ("Empty Folder")
                Exit Sub
            End If
        End With
    
    
        If DyeSet = "DS33" Then
            Call DS33Summary
        ElseIf DyeSet = "DS30" Then
            Call DS30Summary
        ElseIf DyeSet = "Identifiler" Then
            Call IdentifilerSummary
        ElseIf DyeSet = "ProPlus" Then
            Call ProPlusSummary
        ElseIf DyeSet = "SNaPshot" Then
            Call SNaPshotSummary
        ElseIf DyeSet = "ALFP" Then
            Call ALFPSummary
        End If
    
    
    End Sub

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
  •