Run-time error '-2147418113 (8000ffff)': Automation error Catastrophic failur

TTUK

Board Regular
Joined
Apr 5, 2012
Messages
137
Hi All,

I am having the error shown in my subject line when trying to run the below VBA script.
Please can someone please help me to understand how and why this isn't working?! It was working fine the other day!!


Code:
Sub DAY1_8DM_Import()

Application.StatusBar = "Please wait ... IMPORTING DAY 1 8DM"


Dim wbCSV   As Workbook
Dim wsMstr  As Worksheet:   Set wsMstr = ThisWorkbook.Sheets("8DM Day 1 Import")
Dim fPath   As String:      fPath = "\\ttasuk-vsrv010\SHARED\05 Supply Chain\Supplier Schedules\Master Planning Document\8DM Day 1 Import\"    'path to CSV files, include the final \
Dim fCSV    As String
Dim NextCol As Long


Worksheets("8DM Day 1 Import").Range("A:Z").ClearContents


        wsMstr.UsedRange.Clear
        NextCol = 1


fCSV = Dir(fPath & "*.csv")         'start the CSV file listing


    Do While Len(fCSV) > 0
      'open a CSV file
        Set wbCSV = Workbooks.Open(fPath & fCSV)
      
      'copy date into master sheet and close source file
        ActiveSheet.UsedRange.Copy wsMstr.Cells(2, NextCol)
        wbCSV.Close False
      'ready next CSV
        fCSV = Dir
        NextCol = wsMstr.Cells(3, Columns.Count).End(xlToLeft).Column + 1
    
    Loop
        
Call Qty_Calculate




Sheets("8DM Data").Select
    ActiveWorkbook.RefreshAll


Sheets("BOM").Select
    ActiveWorkbook.RefreshAll


Sheets("UPDATE").Select
    ActiveWorkbook.RefreshAll


      
    Application.StatusBar = ""


MsgBox "Update of Day 1 8DM Completed"




End Sub


Thanks!!! :D
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Where in the code does the error occur?
 
Upvote 0
Hi Norie,

It occurs at this point highlighted in bold and red.

Code:
Dim wbCSV   As Workbook
Dim wsMstr  As Worksheet[COLOR=#ff0000][B]:   Set wsMstr = ThisWorkbook.Sheets("Day 1 Import")[/B][/COLOR]
Dim fPath   As String:      fPath = "\\ttasuk-vsrv010\SHARED\05 Supply Chain\Supplier Schedules\Master Planning Document\8DM Day 1 Import\"    'path to CSV files, include the final \
Dim fCSV    As String
Dim NextCol As Long

The Sheet Name, is named "Day 1 Import"
And in the VB Window for Excel Objects it is as the name: Sheet22 (Day 1 Import)


Thanks,
 
Last edited:
Upvote 0
Does it make any difference if you move the assignment of values/references to the variables outwith the declaration section?

Kind of like this.
Code:
Sub DAY1_8DM_Import()
Dim wbCSV As Workbook
Dim wsMstr As Worksheet
Dim fPath As String
Dim fCSV As String
Dim NextCol As Long

    Application.StatusBar = "Please wait ... IMPORTING DAY 1 8DM"

    fPath = "\\ttasuk-vsrv010\SHARED\05 Supply Chain\Supplier Schedules\Master Planning Document\8DM Day 1 Import\"    'path to CSV files, include the final \

    Set wsMstr = ThisWorkbook.Sheets("8DM Day 1 Import")

    Worksheets("8DM Day 1 Import").Range("A:Z").ClearContents

    wsMstr.UsedRange.Clear
    NextCol = 1

    fCSV = Dir(fPath & "*.csv")         'start the CSV file listing

    Do While Len(fCSV) > 0
        'open a CSV file
        Set wbCSV = Workbooks.Open(fPath & fCSV)

        'copy date into master sheet and close source file
        ActiveSheet.UsedRange.Copy wsMstr.Cells(2, NextCol)
        wbCSV.Close False
        'ready next CSV
        fCSV = Dir
        NextCol = wsMstr.Cells(3, Columns.Count).End(xlToLeft).Column + 1

    Loop

    Call Qty_Calculate

    Sheets("8DM Data").Select
    ActiveWorkbook.RefreshAll

    Sheets("BOM").Select
    ActiveWorkbook.RefreshAll

    Sheets("UPDATE").Select
    ActiveWorkbook.RefreshAll

    Application.StatusBar = ""

    MsgBox "Update of Day 1 8DM Completed"

End Sub
 
Upvote 0
Hi Norie,

No the error still appears. I have highlighted where it throws up the error...

Code:
Sub DAY1_8DM_Import()Dim wbCSV As Workbook
Dim wsMstr As Worksheet
Dim fPath As String
Dim fCSV As String
Dim NextCol As Long


    Application.StatusBar = "Please wait ... IMPORTING DAY 1 8DM"


    fPath = "\\ttasuk-vsrv010\SHARED\05 Supply Chain\Supplier Schedules\Master Planning Document\8DM Day 1 Import\"    'path to CSV files, include the final \


[COLOR=#ff0000][B]    Set wsMstr = ThisWorkbook.Sheets("8DM Day 1 Import")[/B][/COLOR]


    Worksheets("8DM Day 1 Import").Range("A:Z").ClearContents


    wsMstr.UsedRange.Clear
    NextCol = 1


    fCSV = Dir(fPath & "*.csv")         'start the CSV file listing


    Do While Len(fCSV) > 0
        'open a CSV file
        Set wbCSV = Workbooks.Open(fPath & fCSV)


        'copy date into master sheet and close source file
        ActiveSheet.UsedRange.Copy wsMstr.Cells(2, NextCol)
        wbCSV.Close False
        'ready next CSV
        fCSV = Dir
        NextCol = wsMstr.Cells(3, Columns.Count).End(xlToLeft).Column + 1


    Loop


    Call Qty_Calculate


    Sheets("8DM Data").Select
    ActiveWorkbook.RefreshAll


    Sheets("BOM").Select
    ActiveWorkbook.RefreshAll


    Sheets("UPDATE").Select
    ActiveWorkbook.RefreshAll


    Application.StatusBar = ""


    MsgBox "Update of Day 1 8DM Completed"


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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