Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Guidance with creating a bespoke .txt

Hi All,

Hoping that someone might be able to give me a push in the right
direction here...please!

I need to have xlvba create a simple two line .cmd file, the contents of
which will be determined via several userforms that the user will have
had to fill in.

I have no problem getting the .cmd to then run in the background using
the Shell commands - it's just the creation of the file ( which is
essentially just a .txt anyway ) and the inputting of the two or so
lines of data.

I would ideally like to create the .cmd then fill in the two lines, then
delete the .cmd at the end, if this is possible.

I would be very grateful for any direction.

Rgds

======
Stuart
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Guidance with creating a bespoke .txt

the following pseudo code should get you going.

Sub Doit()
Dim sStr as String
Dim LineofText As String
Dim rw as Long
rw = 0
Open "C:\CMDFILE\MyFile.cmd" For Output As #1
Print #1, "Echo Off"
print #1, "Dir *.* c:\newfile.txt"
'Close the file
Close #1
Shell "C:\cmdfile\myfild.cmd"
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
On Error Resume Next
Kill "C:\CMDFILE\MyFile.cmd"
On Error goto 0
End Sub

--
Regards,
Tom Ogilvy

"Krayten" wrote in message
om...
Hi All,

Hoping that someone might be able to give me a push in the right
direction here...please!

I need to have xlvba create a simple two line .cmd file, the contents of
which will be determined via several userforms that the user will have
had to fill in.

I have no problem getting the .cmd to then run in the background using
the Shell commands - it's just the creation of the file ( which is
essentially just a .txt anyway ) and the inputting of the two or so
lines of data.

I would ideally like to create the .cmd then fill in the two lines, then
delete the .cmd at the end, if this is possible.

I would be very grateful for any direction.

Rgds

======
Stuart



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Guidance with creating a bespoke .txt

Fantastic - I only needed to modify your code a tiny bit to get the job
done precisely
as I needed -- very grateful to you Tom!

One ? If I may...

The macro failed at the Shell command line.
I am having trouble opening .txt files with the Shell command.

Should it be:

Shell ( C:\Windows\Notepad.exe C:\testfile.txt) , 0

or

Shell "C:\testfile.txt", 0

I'm using xlvba 2003

Thanks again,

Stuart

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Guidance with creating a bespoke .txt

Uh Got it, it should be

Shell ("C:Windows\Notepade.exe C:\testfile.txt")

Thanks anyway!

Stuart

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
colating data from a table - for bespoke report UKMAN Excel Worksheet Functions 4 April 29th 10 04:25 PM
Need some guidance Buxton Excel Worksheet Functions 1 December 25th 07 09:11 PM
Bespoke worksheet for a trader Shevvie Excel Discussion (Misc queries) 0 October 11th 07 05:01 PM
Creating Bespoke Template - how do I bring up a specific data rang Peterwnixon Excel Discussion (Misc queries) 0 January 2nd 07 12:37 PM
Bespoke drop down list robert111 Excel Discussion (Misc queries) 1 July 7th 06 10:23 AM


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"