Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've tried to create this macro using the Shell command which works for
opening Notepad but I can't get the part about putting the date and time into the filename of the Notepad file. The date and time format could have blanks between such as mm dd yyyy hh mm ss but if it has underscore or other characters that is ok. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is a different approach and maybe simpler:
Option Explicit Sub StringToTextFile(ByVal txtFile As String, _ ByVal strString As String) Dim hFile As Long hFile = FreeFile 'Close before reopening in another mode. '--------------------------------------- On Error Resume Next Open txtFile For Input As #hFile Close #hFile Open txtFile For Output As #hFile 'this will make start- and end quotes 'Write #hFile, strString Print #hFile, strString; Close #hFile End Sub Sub test() Dim strFolder As String Dim strFileName As String Dim strExtension As String strFolder = "C:\" strFileName = "File " & _ Format(Date, "dd_mmm_yyyy") strExtension = ".txt" StringToTextFile _ strFolder & strFileName & strExtension, _ "just testing" End Sub RBS "Willy" wrote in message ... I've tried to create this macro using the Shell command which works for opening Notepad but I can't get the part about putting the date and time into the filename of the Notepad file. The date and time format could have blanks between such as mm dd yyyy hh mm ss but if it has underscore or other characters that is ok. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel wants to save an open file to another filename in VBA script | Excel Programming | |||
Newbie, how to save file with date and time as filename | Excel Programming | |||
Date Filename Save as Dialog Macro Thingy!!!!!! | Excel Programming | |||
Can a MACRO prompt for the filename to open and/or save? | Excel Programming | |||
Save Filename+Date+Time? | Excel Programming |