VBA Paste In Notepad & Save

christian2016

Board Regular
Joined
Oct 6, 2016
Messages
123
Hi Guys,

Need help with pasting in notepad and saving file.

Basically I have copied what i needed and just need a VBA code within excel to paste it in notepad and save it as per name in range ("a1") in my spreadsheet.

File to be saved in directory path C:\Temp

Any help is greatly appreciated

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Aug59
[COLOR="Navy"]Dim[/COLOR] DataObj [COLOR="Navy"]As[/COLOR] New MSForms.DataObject
[COLOR="Navy"]Dim[/COLOR] i [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] strOut [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] strFile1 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
    DataObj.GetFromClipboard
      strOut = DataObj.GetText
        strFile1 = "C:\Temp\" & Range("A1").Value & ".txt"
i = FreeFile
Open strFile1 [COLOR="Navy"]For[/COLOR] Binary Access Write [COLOR="Navy"]As[/COLOR] [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=i]#i[/URL] 
  Put [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=i]#i[/URL] , , strOut
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=i]#i[/URL] 
MsgBox "File Created"
Application.CutCopyMode = False
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thanks MickG.

I done it with this code.

Code:
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False


ActiveWorkbook.SaveAs Filename:= _
FilePath & SRNumber, FileFormat:=xlTextWindows, _
CreateBackup:=False
ActiveWindow.Close
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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