opening a text file and keeping it active/open

hearthhrob4gals

Board Regular
Joined
Aug 20, 2014
Messages
142
Hi,

I want to create a text file. copy data from excel into it and display the text file...the below code creates a text file and pastes the data from excel. However, i cant see the text file open. i want the text file to be the active window. any help on this would be appreciated.

VBA Code:
Sub TextFile_Create()

Dim TextFile As Integer
Dim FilePath As String

  FilePath = ActiveWorkbook.Path & "\AuditLog10.txt"
  TextFile = FreeFile

  Open FilePath For Output As TextFile
  Print #TextFile, Sheets("Input").Range("dd1").Value

End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
i suggest you just use a userform with a copy of the text file as a preview. you would have to Shell to Notepad or similar to view the file and then you have issues of having to bring the focus back to excel, and also possible problems with writing to the file while it is in use by another application
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,239
Members
448,555
Latest member
RobertJones1986

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