Solved

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

Posted on 2015-02-04
3
142 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:
Simon 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Conditional Statements 11 40
Binding recordsets to a form 6 27
Change date stored as "short text" YYYYMMDD to MM/DD/YYYY? 27 29
Modify report 8 11
Modern/Metro styled message box and input box that directly can replace MsgBox() and InputBox()in Microsoft Access 2013 and later. Also included is a preconfigured error box to be used in error handling.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

832 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