+ Reply to Thread
Results 1 to 5 of 5

Urgent help Runtime error ‘1004’ Method ‘SaveAs’ of object’-Workbook’ failed ?????

  1. #1
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500

    Urgent help Runtime error ‘1004’ Method ‘SaveAs’ of object’-Workbook’ failed ?????

    Hi

    A user has been receiving this error. I wanted to know if there is perhaps something that triggers this error message off. In my code it saves a workbook to the Floppy Drive (A. I have asked the user to confirm that the disk is in the A: Drive which they confirmed. They have also tried another disk. I have excel 2000 and the user has excel 2003. I dont know if its perhaps a compatiblitie issue.


    Any advise much appreciates

  2. #2
    PatrickS
    Guest

    =?Utf-8?Q?RE:_Urgent_help_Runtime_error_=E2=80=981?==?Utf-8?Q?004=E2=80=99_Method_=E2=80=98SaveAs=E2=80=99_of_object=E2=80=99-?==?Utf-8?Q?Workbo?=

    Would it be possible to post the code that you are having problems with? Also
    just out of curiosity do they have the same problem if they try and save the
    file to the PC hard drive rather than the floppy?

    "funkymonkUK" wrote:

    >
    > Hi
    >
    > A user has been receiving this error. I wanted to know if there is
    > perhaps something that triggers this error message off. In my code it
    > saves a workbook to the Floppy Drive (A. I have asked the user to
    > confirm that the disk is in the A: Drive which they confirmed. They
    > have also tried another disk. I have excel 2000 and the user has excel
    > 2003. I dont know if its perhaps a compatiblitie issue.
    >
    >
    > Any advise much appreciates
    >
    >
    > --
    > funkymonkUK
    > ------------------------------------------------------------------------
    > funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
    > View this thread: http://www.excelforum.com/showthread...hreadid=538783
    >
    >


  3. #3
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    Heres my code which is attached to a button on a userform. unfortunately I will try to ask them to save it to PC but I would prefer it if they dont as this should be an automated procedure.


    Private Sub CommandButton1_Click()
    Sheets("data").Visible = True
    Sheets("data").Select
    Range("f1") = ComboBox1.Value

    Range("A7").Select
    Set exportfind = Cells.Find(What:="download", after:=Range("a7"), LookIn:=xlValues, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False)
    If ActiveCell.Row < 7 Then
    MsgBox ("There is no data for the month you have selected.")
    End If
    If exportfind Is Nothing Then
    MsgBox ("There is no data for the month you have selected.")
    Else
    MsgBox ("Please insert a floppy disk into the floppy drive and when you are ready to export click th OK button.")
    exportplace = Range("b3").Value
    exportname = Range("b2").Value
    exportmonth = Range("k1").Value
    exportfile = "A:\" & exportplace & "-" & exportmonth & "data.csv"
    Range("A7").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=12, Criteria1:="Download"
    Selection.CurrentRegion.Select
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Columns("L:L").Select
    Selection.Delete Shift:=xlToLeft
    Range("A1").Select

    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=exportfile, FileFormat:=xlCSV, _
    CreateBackup:=False
    ActiveWindow.Close

    Selection.AutoFilter
    Application.DisplayAlerts = True
    Range("A7").Select

    'email the data
    mainemail = Range("f2").Value
    Dim ol As Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim newm As Outlook.MailItem
    Set ol = New Outlook.Application
    Set ns = ol.GetNamespace("MAPI")
    On Error Resume Next
    Set newm = ol.CreateItem(olMailItem)
    With newm
    .To = mainemail ' email address to send to
    .Subject = "Stats Return from " & exportname & "-" & exportmonth ' subject of the email
    .Body = "Here are is our Return" ' message in the email
    With .Attachments.Add(exportfile) ' add the file i am using at present
    .DisplayName = "Stats returns from " & exportplace
    End With
    .Send
    End With
    Set ol = Nothing
    Set ns = Nothing
    Set newm = Nothing
    MsgBox ("Your data has been exported to " & mainemail & ".")
    End If
    Sheets("data").Visible = True
    End Sub

  4. #4
    Registered User
    Join Date
    01-20-2006
    Posts
    19

    Wich value?

    wich values are in

    Range("b3").Value
    Range("b2").Value
    Range("k1").Value

    ?

  5. #5
    Tom Ogilvy
    Guest

    =?Utf-8?Q?Re:_Urgent_help_Runtime_error_=E2=80=981?==?Utf-8?Q?004=E2=80=99_Method_=E2=80=98SaveAs=E2=80=99_of_object=E2=80=99-?==?Utf-8?Q?Wo?=

    Have your code save it to the hard drive, then copy it to the floppy. then
    optionally delete it from the hard drive.

    --
    Regards,
    Tom Ogilvy


    "funkymonkUK" wrote:

    >
    > Heres my code which is attached to a button on a userform. unfortunately
    > I will try to ask them to save it to PC but I would prefer it if they
    > dont as this should be an automated procedure.
    >
    >
    > Private Sub CommandButton1_Click()
    > Sheets("data").Visible = True
    > Sheets("data").Select
    > Range("f1") = ComboBox1.Value
    >
    > Range("A7").Select
    > Set exportfind = Cells.Find(What:="download", after:=Range("a7"),
    > LookIn:=xlValues, LookAt _
    > :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
    > MatchCase:= _
    > False)
    > If ActiveCell.Row < 7 Then
    > MsgBox ("There is no data for the month you have selected.")
    > End If
    > If exportfind Is Nothing Then
    > MsgBox ("There is no data for the month you have selected.")
    > Else
    > MsgBox ("Please insert a floppy disk into the floppy drive and when
    > you are ready to export click th OK button.")
    > exportplace = Range("b3").Value
    > exportname = Range("b2").Value
    > exportmonth = Range("k1").Value
    > exportfile = "A:\" & exportplace & "-" & exportmonth & "data.csv"
    > Range("A7").Select
    > Selection.AutoFilter
    > Selection.AutoFilter Field:=12, Criteria1:="Download"
    > Selection.CurrentRegion.Select
    > Selection.Copy
    > Workbooks.Add
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Columns("L:L").Select
    > Selection.Delete Shift:=xlToLeft
    > Range("A1").Select
    >
    > Application.DisplayAlerts = False
    > ActiveWorkbook.SaveAs Filename:=exportfile, FileFormat:=xlCSV, _
    > CreateBackup:=False
    > ActiveWindow.Close
    >
    > Selection.AutoFilter
    > Application.DisplayAlerts = True
    > Range("A7").Select
    >
    > 'email the data
    > mainemail = Range("f2").Value
    > Dim ol As Outlook.Application
    > Dim ns As Outlook.NameSpace
    > Dim newm As Outlook.MailItem
    > Set ol = New Outlook.Application
    > Set ns = ol.GetNamespace("MAPI")
    > On Error Resume Next
    > Set newm = ol.CreateItem(olMailItem)
    > With newm
    > .To = mainemail ' email address to send to
    > .Subject = "Stats Return from " & exportname & "-" & exportmonth
    > ' subject of the email
    > .Body = "Here are is our Return" ' message in the email
    > With .Attachments.Add(exportfile) ' add the file i am using
    > at present
    > .DisplayName = "Stats returns from " & exportplace
    > End With
    > .Send
    > End With
    > Set ol = Nothing
    > Set ns = Nothing
    > Set newm = Nothing
    > MsgBox ("Your data has been exported to " & mainemail & ".")
    > End If
    > Sheets("data").Visible = True
    > End Sub
    >
    >
    > --
    > funkymonkUK
    > ------------------------------------------------------------------------
    > funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
    > View this thread: http://www.excelforum.com/showthread...hreadid=538783
    >
    >


+ Reply to Thread

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