Results 1 to 3 of 3

Run time error when using activeworkbook.saveas

Threaded View

CJPHX Run time error when using... 07-06-2010, 09:52 AM
romperstomper Re: Run time error when using... 07-06-2010, 10:17 AM
CJPHX Re: Run time error when using... 07-06-2010, 11:11 AM
  1. #1
    Forum Contributor
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    107

    Question Run time error when using activeworkbook.saveas

    Mornign all,
    My company is in the process of upgrading to 2007 so I am ensuring all macros run in 2007. So far most of them have. Howeer I am currently getting a runtime error when it get's to the saveas function.

    Run-time error '1004':
    Method 'SaveAs' of Object'_Workbook' failed

    I have posted the code below. When I debug it it highlights the saveas feature.

    Sub DBUpdate()
    
    Dim FileDate    As String
    
    FileDate = Application.InputBox("Please enter file date: (MM/DD/YYYY)", _
                                    "Enter Date", Format(Date - 1, "MM/DD/YYYY"))
                                    
    If FileDate = "False" Then Exit Sub
    
    
    
    Worksheets("UpdatingDB").Visible = xlSheetVisible
    
    Sheets("UpdatingDB").Activate
    
    
    Application.StatusBar = ("Please wait ... calculations in progress!!")
    Application.Cursor = xlWait
    
    
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    
    
    Dim c00         As String
    Dim c01         As String
    Dim MyArr       As Variant
    Dim MyArrCnt    As Long
    
    
    c00 = "\\wpccp001if\Apps\C3PO\PMG - Ben's\Network MPT Inclusion\ECMReports_Daily\"
    c01 = c00 & Format((FileDate), "yyyymmdd")
    MyArr = Array(" 224", " 223", " 222", " 221", " 215", " 214", " 213", " 212", " 211", " 210", " 205", " 204", " 203", " 202", " 201", " 200")
        
    On Error Resume Next
        Do
            Workbooks.Add c00 & Dir(c01 & MyArr(MyArrCnt) & "*campdata.csv")
            If Err.Number > 0 Then
                Err.Number = 0
                MyArrCnt = MyArrCnt + 1
            Else
                Exit Do
            End If
            If MyArrCnt > UBound(MyArr) Then
                MsgBox "Campdata file not found.  Please ensure file is available."
                Application.ScreenUpdating = True
                Sheets("Macros").Select
                Application.Cursor = xlDefault
                Application.StatusBar = False
                Exit Sub
            End If
        Loop
    
    On Error GoTo 0
        
         
        ActiveWorkbook.SaveAs FileName:= _
            "\\EMC-NAS4.nac.ad.aexp.com\Groups47\Fraud\Ops Desk\Reports and Trending\RCSN Data\campdata.xls", FileFormat:= _
            xlExcel9795, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
            False, CreateBackup:=False
        ActiveWorkbook.Close
    Last edited by CJPHX; 07-06-2010 at 11:11 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1