+ Reply to Thread
Results 1 to 3 of 3

Saving Programmatically Suggestions or Help

  1. #1
    Registered User
    Join Date
    08-13-2005
    Posts
    7

    Lightbulb Saving Programmatically Suggestions or Help

    My research in this area has hit some dead ends so I am asking the community for some suggestions or hints to figure out my situation.

    I am importing a fixed-width text file and reformatting it in Excel. When this file is imported a new workbook is created with the filename of the text file. My problem is that I am trying to figure out a way to save this workbook programmatically from another workbook without user intervention.

    My attempts to save it so far have met with halfway success. I can get a file save to a specified directory with the correct filename. But it still prompts the end user to save the file when you try to close the workbook. More importantly, when opening the file that was saved Excel starts an import text file routine rather than opening the formatted text file that was created in the workbook.

    The only method I have found that's somewhat close is the SaveAs method. I'm pretty sure that the reason Excel is still trying to open the saved workbook as a text file has something do to with the type of file it is when originally opened.

    Can someone suggest some methods or properties to investigate or maybe offer a suggestion as to how to approach this problem? I've gone through all my Excel books and Help but can't seem to find much on the subject.

  2. #2
    Jim Rech
    Guest

    Re: Saving Programmatically Suggestions or Help

    >>I'm pretty sure that the reason Excel is still trying to open the saved
    >>workbook as a text file has something do to with the type of file it is
    >>when originally opened.


    My guess is that when you save it you do not change the Save As type to
    "Excel Workbook". I suspect you're just saving it back as text. You should
    be doing something like:

    ActiveWorkbook.SaveAs "C:\MyFile", xlWorkbookNormal

    Specifying an XLS extension is not enough.

    --
    Jim
    "rayd8" <[email protected]> wrote in
    message news:[email protected]...
    |
    | My research in this area has hit some dead ends so I am asking the
    | community for some suggestions or hints to figure out my situation.
    |
    | I am importing a fixed-width text file and reformatting it in Excel.
    | When this file is imported a new workbook is created with the filename
    | of the text file. My problem is that I am trying to figure out a way to
    | save this workbook programmatically from another workbook without user
    | intervention.
    |
    | My attempts to save it so far have met with halfway success. I can get
    | a file save to a specified directory with the correct filename. But it
    | still prompts the end user to save the file when you try to close the
    | workbook. More importantly, when opening the file that was saved Excel
    | starts an import text file routine rather than opening the formatted
    | text file that was created in the workbook.
    |
    | The only method I have found that's somewhat close is the SaveAs
    | method. I'm pretty sure that the reason Excel is still trying to open
    | the saved workbook as a text file has something do to with the type of
    | file it is when originally opened.
    |
    | Can someone suggest some methods or properties to investigate or maybe
    | offer a suggestion as to how to approach this problem? I've gone
    | through all my Excel books and Help but can't seem to find much on the
    | subject.
    |
    |
    | --
    | rayd8
    | ------------------------------------------------------------------------
    | rayd8's Profile:
    http://www.excelforum.com/member.php...o&userid=26267
    | View this thread: http://www.excelforum.com/showthread...hreadid=398681
    |



  3. #3
    Registered User
    Join Date
    08-13-2005
    Posts
    7
    Jim,

    Thanks, xlWorkBookNormal is what I was looking for. I plugged it into my code and everything works as expected. I appreciate your help, this last detail is what I needed to finish my project.

+ 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