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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,223,786
Messages
6,174,547
Members
452,571
Latest member
MarExcelTips

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