how to save Txt Desktop using excel 2010?

elsg

Active Member
Joined
Mar 16, 2013
Messages
295
how to save Txt in Desktop using excel 2010?
Code:
Sub Save_Desktop()   Application.ScreenUpdating = False
       Dim Pasta As String
       Application.DisplayAlerts = False
       template_file = ActiveWorkbook.FullName
                    
      fileSaveName = "C:\Documents and Settings\master\Desktop\Txt" + VBA.Strings.Format(Now, "dd-mm-yyyy") + ".txt"
      Dim newBook As Workbook
      Dim plan As Worksheet
      Dim Intervalo As Range
       
   Set Intervalo = [C5:H22]
       
   Set newBook = Workbooks.Add
    ThisWorkbook.Activate
     Intervalo.Copy
      newBook.Sheets(1).[A1].PasteSpecial xlPasteValues
       
        For i = newBook.Sheets.Count To 2 Step -1
         newBook.Sheets(i).Delete
          Next
  newBook.SaveAs Filename:=fileSaveName, FileFormat:=xlTextWindows, CreateBackup:=False
  newBook.Close SaveChanges:=True
  Set newBook = Nothing
  Application.ScreenUpdating = True
  End Sub

Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try:

Code:
fileSaveName = CreateObject("Wscript.Shell").SpecialFolders("Desktop") & "\Txt" + <ACRONYM title="visual basic for applications">VBA</ACRONYM>.Strings.Format(Now, "dd-mm-yyyy") + ".txt"
 
Upvote 0

Forum statistics

Threads
1,216,150
Messages
6,129,154
Members
449,488
Latest member
qh017

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top