+ Reply to Thread
Results 1 to 8 of 8

Trying to save a worksheet as a new workbook

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Trying to save a worksheet as a new workbook

    • I have a sheet full of data.
    • All this long I had written the code to save the selected cells as a PDF.
    • But now I want it to be saved as a separate file. In this case, I believe, first the VBA will have to open a new workbook. Then copy paste this sheet onto one of the sheets in the workbook . then save the .XLM file.


    The code I have now is :

    Please Login or Register  to view this content.
    What I tired to do :

    Please Login or Register  to view this content.
    But didn't work... Any idea how to resolve this?
    Last edited by subbby; 05-08-2014 at 01:59 PM. Reason: SOLVED

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

    Re: Trying to save a worksheet as a new workbook

    You can create a new workbook from a single sheet like this.
    Please Login or Register  to view this content.
    You can the save the new workbook as an xlsm like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Trying to save a worksheet as a new workbook

    Appreciate your help. It worked...

    Thanks.

  4. #4
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Trying to save a worksheet as a new workbook

    Quote Originally Posted by Norie View Post
    You can create a new workbook from a single sheet like this.
    Please Login or Register  to view this content.
    You can the save the new workbook as an xlsm like this.
    Please Login or Register  to view this content.

    It worked for a while.. then all of a sudden give this error

    "this extension cannot be used with the selected file type. Change the file extension in teh File Name text box or select a different file type by changing teh SAVE as type..."

    So here is how my code looks now

    Please Login or Register  to view this content.
    Since my code asks the user to input the file name ("fName") , is there a way it by default selects Save as type as "Excel Macro-Enabled Workbook" ???

    I thought that the line in ur code should do it ... but it isnt. I have to manually change it to "Excel Macro-Enabled Workbook"

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

    Re: Trying to save a worksheet as a new workbook

    What type of files are you dealing with?

    What's you default save as file type?

  6. #6
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Trying to save a worksheet as a new workbook

    Default it depends from user to user. This program is used by many engineers. Some may have PDF as default, some as XLS and some as XLM

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

    Re: Trying to save a worksheet as a new workbook

    So the user could be opening PDF files?

  8. #8
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Trying to save a worksheet as a new workbook

    Quote Originally Posted by Norie View Post
    So the user could be opening PDF files?
    Norie , I quite didnt understand ....

    My need is to save the file as a XLSM. The above code does it. However I ahve to double check the "SAVE AS" option in the windows dialog box if its XLSM. If by default its PDF, the above code gives error

+ 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. [SOLVED] Export/Save a worksheet in a workbook without changing the name of the workbook?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2013, 06:04 PM
  2. [SOLVED] Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name
    By schmidt62 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2012, 12:00 AM
  3. [SOLVED] Copy certain cells before save from a worksheet in one workbook to a worksheet in another
    By Marianne Rachmann in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2012, 07:16 PM
  4. Incremental save. Save just one worksheet of a workbook?
    By dylanemcgregor in forum Excel General
    Replies: 2
    Last Post: 09-09-2009, 05:19 PM
  5. Replies: 3
    Last Post: 06-27-2005, 01:05 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