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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,215,681
Messages
6,126,192
Members
449,298
Latest member
Jest

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