+ Reply to Thread
Results 1 to 9 of 9

file Save As issue

  1. #1
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    file Save As issue

    I'm trying to use a macro to take a .txt file, re-format it and save as .xls. The .xls already exists and I want to copy over it. I also want to close the macro excel file, without saving, so that it can be reused. The code below appears to do just that, but when I try to open the newly created .xls file, I recieve the following prompt "This File you are trying to open, 'CompanyConvert.xls', is in a different format than specified by the file extension. Verify that the file is not corrupt and is from a trusted source before opening the file. Do you want to open the file now?". This is causing issues downstream. There has to be something screwy with how I'm saving this file. Thoughts?

    Please Login or Register  to view this content.
    Thanks in advance,

    Ray

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: file Save As issue

    Ray

    Try explicitly specifying th file format when saving.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: file Save As issue

    Hi, Ray,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: file Save As issue

    Quote Originally Posted by Norie View Post
    Ray

    Try explicitly specifying th file format when saving.
    Please Login or Register  to view this content.
    This worked great Norie, Thank you for the quick response

    Ray

  5. #5
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: file Save As issue

    Quote Originally Posted by HaHoBe View Post
    Hi, Ray,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Thank you too for the quick response HaHoBe, greatly appreciated!

  6. #6
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: file Save As issue

    My apologies for unresolving this but another issue popped up while saving this file. Becuase the file now already exists and Im trying to save a copy over it, I get a pop up that says "The File name "xxxx.xls" already exists in this location. Do you want to replace it?". Is there logic I can build into the macro that automatically chooses 'Yes' and avoid the manual process for clicking 'Yes' altogether?

    Please Login or Register  to view this content.
    Thanks,
    Ray

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: file Save As issue

    Hi, rdowney79,

    I think my sample code covers exactly the problem that you ask for right now.

    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: file Save As issue

    Quote Originally Posted by HaHoBe View Post
    Hi, rdowney79,

    I think my sample code covers exactly the problem that you ask for right now.

    Ciao,
    Holger
    that worked great, thanks. One last question. The below code saves the file and closes the workbook. How do I use the macro to close out of Excel entirely?

    Please Login or Register  to view this content.
    Thanks,
    Ray

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: file Save As issue

    Hi, rdowney79,

    maybe like this (but I donīt favour this approach if I canīt control how mayn othe rworkbooks are open):
    Please Login or Register  to view this content.
    Ciao,
    Holger

+ 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. Replies: 1
    Last Post: 09-05-2013, 02:39 PM
  2. Replies: 1
    Last Post: 08-29-2013, 07:29 AM
  3. [SOLVED] Save worksheet as seperate workbook problem- File name issue
    By ANDREWA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2012, 07:16 AM
  4. File save count issue
    By biznez in forum Excel General
    Replies: 6
    Last Post: 12-15-2009, 10:59 AM
  5. Replies: 0
    Last Post: 03-09-2005, 06:06 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