+ Reply to Thread
Results 1 to 6 of 6

Trouble with file destination

  1. #1
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    Trouble with file destination

    Here's my code to save a file and place it in a certain location on c drive. I get a message "Object doesn't support this property or method"

    But the file is created with the correct file name, but is placed or defaulted to "My Documents"

    What's missing or out of place?

    Sub Test()
    Activesheet.Copy
    ActiveWorkbook.SaveAs Format (Range("B1"), "mm-dd-yyyy")
    ActiveWorkbok.Open "c:\ArchiveFolder.xls"
    ActiveWorkbook.Close
    End Sub


    Thanks
    EMoe

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello EMoe,

    You are not using the Format argument correctly. Here are the code corrections


    Sub Test()
    Activesheet.Copy
    Range("B1").NumberFormat = "mm-dd-yyyy"
    ActiveWorkbook.SaveAs FileName:="c:\ArchiveFolder " & Range("B1") & ".xls", FileFormat:=xllWorkbookNormal
    ActiveWorkbook.Close
    End Sub


    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 05-18-2005 at 04:27 AM.

  3. #3
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196
    Leith,

    I don't know what's wrong.

    I get a RED X with error 400.

    The only thing it does is open a new workbook at the bottom of the screen, then the error message.

    EMoe

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello EMoe,

    Well, it's progress. Error 400 "Form already displayed, can't showmodally" means somewhere in your code you have UserForm.Show. Since the User Form is already displayed, executing the command again without hiding or unloading the form generates this error. This is not related to creating and saving the new workbook. Take a look in your code and remove the UserForm.Show command.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196
    Thanks for the speedy reply,

    I'll try it, and post a reply later.

    Thanks again.

  6. #6
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    Another attempt to save worksheet in folder

    This was my first attempt:

    Sub Test()
    Activesheet.Copy
    ActiveWorkbook.SaveAs Format (Range("B1"), "mm-dd-yyyy")
    ActiveWorkbok.Open "c:\ArchiveFolder.xls"
    ActiveWorkbook.Close
    End Sub


    Someone was kind enough to help me edit it to this:

    Sub Test()
    Activesheet.Copy
    Range("B1").NumberFormat = "mm-dd-yyyy"
    ActiveWorkbook.SaveAs FileName:="c:\ArchiveFolder " & Range("B1") & ".xls", FileFormat:=xllWorkbookNormal
    ActiveWorkbook.Close
    End Sub


    The Problem with this one was, that I was getting an error 400 code. I was told that I may have some conflict with a userform, which I don't think that I do.

    I tried this which does work, however it saves it as test, which it should because this is the way it's programmed.

    How do I do a SaveAS filename that is in cell "C1" on the worksheet?
    Everytime the user hits the archive button, it must be saved with the current date, which I have as =today() in cell "C1"

    Sub test()
    ActiveSheet.Copy
    ActiveWorkbook.SaveAs Filename:="C:\ArchiveTestFolder\test.xls"
    ActiveWorkbook.Close
    End Sub


    Thanks,
    EMoe

+ 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