• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Export notepad file to be save on same path of macro file

Ruma

New Member
Hi,


Am using a macro to copy paste data from an excel file (excel template) into a notepad.

Currently the macro is saving the notepad in a specific path, however I want the notepad to be saved in the same path where excel file/template is saved. Be it desktop or any share drive.

Please note, below is the code am currently using.

Thanks,
Ruma

Code:
Public Sub CopyToNotepad()
Dim strPath As String: strPath = "\\crb.apmoller.net\pnqgscshare\BCO\06. Business Process Support\In House Cash - IHC\MT940 Automation\" & Range("E1").Value & ".txt"
Dim intFF As Integer: intFF = FreeFile()
Open strPath For Output As #intFF
Print #intFF, Join(Application.Transpose(Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Value), vbCrLf)
Close #intFF
End Sub
 
May be to replace this line
Code:
Dim strPath As String: strPath = "\\crb.apmoller.net\pnqgscshare\BCO\06. Business Process Support\In House Cash - IHC\MT940 Automation\" & Range("E1").Value & ".txt"
with this line
Code:
Dim strPath As String: strPath = ThisWorkbook.Path & "\" & Range("E1").Value & ".txt"
 
Back
Top