+ Reply to Thread
Results 1 to 10 of 10

Code to make copy of workbook in the same folder?

  1. #1
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Code to make copy of workbook in the same folder?

    Hello dear ExcelForum!

    I need vba code to: upon activatting form contttrol button, wich triggers another code inside workbook, please dear Excel, make a copy of workbook in the same folder eg. BOOK1-Copy.xlsm

    Thanks in advance, God Bless!

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Code to make copy of workbook in the same folder?

    Like this one ?
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: Code to make copy of workbook in the same folder?

    File damaged, unable to open.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: Code to make copy of workbook in the same folder?

    @porucha vevrku

    Sorry for off-topic interjection:

    Although there is no official rule regarding this behavior, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.

    Thanks again for all your hard work here!
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Code to make copy of workbook in the same folder?

    Quote Originally Posted by B.W.B. View Post
    File damaged, unable to open.
    It is not damaged, I have downloaded it and it is working - this is workbook from old excel 2k.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: Code to make copy of workbook in the same folder?

    There is an issue with later versions of Excel 2010 and on opening .xls files from the internet. I cannot open your file either. I have tried the workarounds that Google offers to no avail at this time. Please re-read my post #4 above and supply a solution in the body of the thread.

    Meanwhile, I am still looking for a workaround that will allow me to open .xls files.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: Code to make copy of workbook in the same folder?

    ok. Solved the issue of opening the file.

    1. Open control panel in your windows PC
    2. go to Programs
    3. Uninstall a Program
    4. Highlight MS Office
    5. Click on Change at the top
    6. A repair program will run for about 4 minutes.
    7. File should be available to open

  8. #8
    Forum Contributor
    Join Date
    11-26-2014
    Location
    Bosnia&Herzegovina
    MS-Off Ver
    Office2013
    Posts
    281

    Re: Code to make copy of workbook in the same folder?

    Please Login or Register  to view this content.
    Thank you so much, but I need to modify this, i need to overwright existing book1-copy.xlsm file inside folder. How to do that?

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Code to make copy of workbook in the same folder?

    Check if the file(workbook) exist in that folder. If so, delete it before copying.

  10. #10
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Code to make copy of workbook in the same folder?

    Read about the "SaveCopyAs" method and see if that's what you want and to check physically, how does this code work, nothing else.
    From MS help: "SaveCopyAs Method - Saves a copy of the workbook to a file but doesn't modify the open workbook in memory."
    This code will overwrite the file with the same name.

+ 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. Copy a Range from each workbook in a folder to another folder
    By Romina in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2015, 05:53 AM
  2. Replies: 1
    Last Post: 01-06-2015, 10:13 AM
  3. Copy a Range from each workbook in a folder to another folder
    By Romina in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2015, 06:40 AM
  4. Copy a Range from each workbook in a folder to another folder
    By Romina in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2015, 05:44 AM
  5. Code to create New Folder (if doesn't exist) and then Save Workbook to folder
    By jenhawley in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2013, 03:09 PM
  6. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  7. [SOLVED] Copy Values From Each Workbook in Folder to a Single Sheet in New Workbook +Workbook names
    By Arsham24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 07:42 PM

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