Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2015-02-04
3
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
Simon earned 2000 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 11

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

618 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