Results 1 to 4 of 4

Thread: Creating a macro for a backup button

  1. #1
    Join Date
    May 2008
    Posts
    979

    Creating a macro for a backup button

    I am a beginner in macro. In my excel file, I want to put a button which can take a back up in the same Excel file but in another format.

    The file will be saved in .csv format.

  2. #2
    Join Date
    May 2008
    Posts
    685

    Re: Creating a macro for a backup button

    The below is an example in which I have the filename (without .xls).

    The active file is saved in .csv file without closing it.

    Code:
     Sub backup_file_csv () 
       rep_backup = "E:\file_csv" 
            filename = activeworbook.name 
      if instr (filename,".xls")> 0 then  
      filename_csv = mid (filename, instr (filename,".xls") -1, len (filename) - 3) & "csv" 
          Application. DisplayAlerts = False 
          ActiveWorkbook. SaveAs Filename: = rep_backup & filename_csv, _ 
              FileFormat: = xlCSV, CreateBackup: = False 
        Application. DisplayAlerts = True 
      else         
       msgbox "The file is not an active file with extension .xls, no treatment done" 
      End if  
      End Sub

  3. #3
    Join Date
    May 2008
    Posts
    979

    Re: Creating a macro for a backup button

    Thank you for your help. I don't know if it was not possible to go through simple manipulation of an object? Or is it mandatory to go through the code?

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: Creating a macro for a backup button

    I do not understand the meaning of what you are trying to say.

    Otherwise, there is the possibility: in the File menu -> Save As - CSV file type

    This is because at each record, there is a warning message which prevents the loss of information due to the change in format.

Similar Threads

  1. How to rename from button with macro in Microsoft Excel
    By Kanshin in forum MS Office Support
    Replies: 16
    Last Post: 24-02-2012, 01:59 PM
  2. Help for Creating a Backup MX Server
    By UseME in forum Networking & Security
    Replies: 5
    Last Post: 24-03-2010, 05:48 PM
  3. Replies: 3
    Last Post: 09-12-2009, 07:39 PM
  4. Creating macro to insert Excel sheets
    By KABIRA16 in forum Software Development
    Replies: 3
    Last Post: 07-12-2009, 09:29 PM
  5. Replies: 5
    Last Post: 06-11-2008, 01:21 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
  •  
Page generated in 1,751,670,089.75240 seconds with 16 queries