+ Reply to Thread
Results 1 to 3 of 3

Basic file save question

  1. #1
    Registered User
    Join Date
    09-24-2008
    Location
    San Jose, CA
    Posts
    9

    Basic file save question

    Hello

    I am working on a Macro that should export "Sheet2" to the desktop as tab delimited text. I attached the Macro to a button that lives on "Sheet1". This .xls will be used by many different people.

    I am encountering problems:

    - The file should be saved to the user's desktop, but the Macro specifically references MY desktop (i.e. CHDir "C:\Documents and Settings\spdorsey\Desktop\filename.txt"). How do I make it ALWAYS save to the desktop for other users?


    - After the tab-delimited file exports, Excel thinks that my file is now a .txt file, and not a .xls file. I need the original .xls file to be open (for further editing), not the saved .txt. How do I do this?


    - I want Sheet2's text to be exported, not Sheet1's. What syntax do I use to specify Sheet2's content to be saved?


    - Is it possible to alter the file name being saved?

  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 spdorsey,

    This macro will create a Tab Delimited Text File from "Sheet2". It will rename it as "Text Copy of" + the active workbook's name. Change the string for NewName to name you will use. Your workbook will remain the same.
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    09-21-2014
    Location
    Riyadh,Saudi Arabia
    MS-Off Ver
    8
    Posts
    1

    Re: Basic file save question

    Error on this line.... .SaveAs NewName, xlTextWindows
    It does save it, but the error comes on the line above

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How do you save the VB code so that it is independent of any workbook?
    By leon2424 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2008, 06:15 AM
  2. basic vbe question
    By leon2424 in forum Excel General
    Replies: 1
    Last Post: 07-31-2008, 06:06 AM
  3. Using String as filename in Save As not recognised by Dir
    By NoCanDo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2008, 05:49 PM
  4. Save file, create .pdf, (Now delete .xls file)
    By daniels012 in forum Excel General
    Replies: 4
    Last Post: 03-30-2007, 05:14 PM
  5. save newly copied excel file with no macros
    By Jlong1980 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2006, 10:48 AM

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