Solved

Code needed to create a blank text file after a macro is done in Access

Posted on 2015-02-04
3
134 Views
Last Modified: 2016-02-10
I have a macro that runs a series of 20-25 queries, a function at the end.  What is the VBA code for simply creating a blank text file and copying to a folder.

File Path:  C\MyShare
File Name Name Must be:  accessdone.txt

My developer wrote a code that emails reports when my macro is done, he wants a file dropped in a specific folder on our network with a specific name.

Is this possible?
0
Comment
Question by:gracie1972
3 Comments
 
LVL 18

Accepted Solution

by:
SimonAdept earned 500 total points
ID: 40589715
Add these lines to the bottom of your code.

 Dim fileNum As Long
Dim outputFile As String
    
fileNum = FreeFile 'Get the next free filehandle
Open "C:\MyShare\accessdone.txt" For Output As #fileNum 'open the file for writing
Close #fileNum 'close the output file.

Open in new window

0
 

Author Closing Comment

by:gracie1972
ID: 40590129
Thank You!
0
 
LVL 10

Expert Comment

by:HuaMinChen
ID: 40590157
Try
    Dim flsys
    Set flsys = CreateObject("scripting.filesystemobject")
    Set fl = flsys.createtextfile("C:\MyShare\accessdone.txt")

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now