I need to copy a range of cells A1:A20 from worksheet: Assy_txt_export
and paste it into NOTEPAD.
Also is there a way to name the textfile using the data from cell A24
from worksheet: Assy_txt_export.
Andrew P was nice enough to make this version for me, but I need to replace the Sub(test)) portion with a notepad command "Shown Below". (I'm having issues with Quotes in the text file) and Notepad seems to take care of this issue.
From AndY P
---------------------------------------------
-----------------------------------------------![]()
Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _ (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias "SHGetPathFromIDListA" _ (ByVal pidl As Long, ByVal pszPath As String) As Long Public Type SHITEMID cb As Long abID As Byte End Type Public Type ITEMIDLIST mkid As SHITEMID End Type Public Const MAX_PATH As Integer = 260 Public Const CSIDL_DESKTOP = &H0 '// The Desktop - virtual folder Public Function fGetSpecialFolder(CSIDL As Long) As String Dim sPath As String Dim IDL As ITEMIDLIST fGetSpecialFolder = "" If SHGetSpecialFolderLocation(0, CSIDL, IDL) = 0 Then sPath = Space$(MAX_PATH) If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then fGetSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "" End If End If End Function Sub Test() Dim ShNew As Worksheet Dim FName As String Dim Folder As String Set ShNew = Worksheets.Add With ThisWorkbook.Worksheets("Assy_txt_export") .Range("A1:A20").Copy ShNew.Range("A1") FName = .Range("A24").Value End With Folder = fGetSpecialFolder(CSIDL_DESKTOP) FName = Folder & Application.PathSeparator & FName With ShNew .SaveAs Filename:=FName, FileFormat:=xlTextWindows Application.DisplayAlerts = False .Delete Application.DisplayAlerts = True End With End Sub
I found this part on a forum, but I don't know anything about VB.
Can someone tweek it so it shows it is copying the info from worksheet: Assy_txt_export
And have it name the text file using the data from cell A24 from the same worksheet?
**************************************
****************************************![]()
Sub notepad() Range("A1:A20").Copy 'Start Notepad And let it recieve focus Shell "notepad.exe", vbNormalFocus 'Send the keys CTRL+V To Notepad (i.e the window that has focus) SendKeys "^V" ' End Sub
Feel free to contact me @: r.a.willette@na.modine.com
This way I can send a powerpoint slide showing what I'm trying to do.
Thank you for your support
Rob











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks