So you need to end off a procedure by moving a file?
This video shows you how to use the FileSystemObject
and vba to move a file out of one directory into another?
Well, this video shows you how to do it…
Option Compare Database '======================================================== 'DATABASE DESIGNED & CODED BY LOEBLCOM SERVICES 2013 'ERIK LOEBL(713)409-7041 'EMAIL: erik@loeblcomservices.com 'WEB: http://loeblcomservices.com '======================================================== Private Sub btnCreateTable_Click() Dim strFileName As String strFileName = "rptAddresses" DoCmd.OutputTo acOutputReport, strFileName, acFormatPDF, CurrentProject.Path & "\" & strFileName & ".pdf" 'move file to sent directory move_file strFileName End Sub Sub move_file(filename) Dim objFSO As Object 'Dim objFSO As FileSystemObject Dim strFromFile As String Dim strToFile As String strFromFile = CurrentProject.Path & "\" & filename & ".pdf" 'Your folder needs to be called "complete" strToFile = CurrentProject.Path & "\complete\" & filename & ".pdf" 'late binding Set objFSO = CreateObject("Scripting.FileSystemObject") 'early binding - need library reference to "Microsoft Scripting Runtime" 'Set objFSO = New FileSystemObject objFSO.MoveFile strFromFile, strToFile MsgBox "The folder is moved from " & strFromFile & " to " & strToFile End Sub
Click here for the database and the code:
vba-move-file.mdb
Find Error Line Number in VBA With Erl
In this post you are going to find out a way of handling errors in your code with the Erl function. Erl displays the last label before the error Another alternative error handling solution is using labels at each point in long procedure. Here we get a random error: Here is the code behind the […]
Here Is A Customized Msgbox VBA Example
Here is an example of a customized VBA Msgbox. We giving some richtext and customizable flair to the rather ordinary message box. The following code provided with the code after the screenshot, is going to provide you with the ability to really make the ordinary message box shine! Sub MsgboxVBAExamples() Dialog.Box “VBAHowTo.com is your source […]
How To Use The VBA Input Box Cancel Button To Exit Sub
This post will demonstrate how you can use the VBA input box cancel button to exit the sub procedure. When you click the “Cancel” button on the input box, you return a null (blank) value, and knowing this information, you can exit the sub procedure. Here is an example: Sub VBAInputBoxCancel() Dim strResponse As […]
VBA Debug Part 2
In this video I talk about VBA Debug aspects like the Immediate Window, Local Window and Watch Window. …also we use the “debug.print” statement to print a value to the Immediate window. The Local Window is useful to view the current state of all the variables present in the current sub procedure. The Watch Window […]