Results 1 to 2 of 2

Can't control directory file is written to.

Threaded View

mike grottola Can't control directory file... 03-01-2014, 01:55 PM
ajryan88 Re: Can't control directory... 03-02-2014, 10:48 PM
  1. #1
    Registered User
    Join Date
    03-01-2014
    Location
    New Jersey, United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Can't control directory file is written to.

    The script below writes a ".csv" file to the same directory that contains the workbook the macro, "foo" is run from. I'd like help to change the script to always write the file to a separate directory which is: "c:\etc\upload"
    Sub Foo()
    Dim wbSource As Workbook
    Dim wsSource As Worksheet
    Dim wbDest As Workbook
    Dim fName As String
    fName = Range("F1")
    'References
    Set wbSource = ActiveWorkbook
    Set wsSource = ActiveSheet
    Set wbDest = Workbooks.Add
    
    'Copy range on original sheet
    wsSource.Range("Q26:AX230").Copy
    
    '----------------------------
    'Save in new workbook
    wbDest.Worksheets(1).Cells(1, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    Application.CutCopyMode = False
    
    'Save new csv file
    wbDest.SaveAs fName, xlCSV
    
    wbDest.Close SaveChanges:=True
    '----------------------------
    
    End Sub
    Last edited by vlady; 03-02-2014 at 08:55 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 05-21-2013, 08:22 AM
  2. Replies: 0
    Last Post: 01-27-2013, 12:13 PM
  3. Need VBA code to search file in directory and sub-directory and show result
    By johnchencanada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2012, 11:13 PM
  4. Saving file in current directory after accessing file in another directory
    By vuxsa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2011, 11:37 AM
  5. Replies: 3
    Last Post: 06-11-2009, 07:08 PM

Tags for this Thread

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