?
Solved

how to 1>create a txt file 2>run a exe file

Posted on 2005-04-06
12
Medium Priority
?
190 Views
Last Modified: 2010-05-02
Hi experts,

May I know how to create a txt file and later also can open, write to and close it in VBA script.

Also may you give suggestion how to run a exe file in VBA script.

Thanks,

Turbot
0
Comment
Question by:turbot_yu
  • 5
  • 4
  • 2
11 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 13724365
1) Create a textfile and write something in it, through in vb-script

Dim objFile, strFile, strFilePath

strFilePath = "c:\TestFile.txt"
Set objFile = CreateObject("Scripting.FileSystemObject")
Set strFile = objFile.CreateTextFile(strFilePath, True)
strFile.WriteLine("This was made using VBScript.")
strFile.Close
2) Run an exe

You can use the Shell command.  Like this:

Shell("notepad.exe")

replace notepad.exe with the path and filename of the exe you want to run.
0
 

Author Comment

by:turbot_yu
ID: 13724448
How to run the exe in background?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13724510
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:turbot_yu
ID: 13724534
Hi, is there any way to clean all the txt in the txt file fitrts and then put a paragraph in it
0
 

Author Comment

by:turbot_yu
ID: 13724545
Also may I know how to kill the exe file after it finish the task.
Thanks
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13724617
Normally you ask only one question at the time. You asked already 2 questions to start with (so far no problem), but now you keep asking other questions... That's not the purpose !
0
 

Author Comment

by:turbot_yu
ID: 13724788
ok, let me start new ones
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13724864
About the killing of the exe ... -> is it still running or is it inactive ? If it's inactive, you just can use the kill-statemen which will delete the file
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13724917
I guess if you create the textfile like the way I showed above, it will be overwritten (and be empty). Put a paragrahp on it, I'm not sure, start your text and add a empty line between paragraphs ?
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 14308706
Its been more than 21 day's since a comment has been posted. I am going to leave this question for cleanup.
Recommend: [Accept: Dhaest comment]
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 14310209
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:

[Accept: Dhaest comment]

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

egl1044
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question