mkdir export

L

ll

Hi,
I am working with a database which exports an Excel report. I need to
create a new folder just for the downloads (by use of mkdir). My
question is, where would I put this mkdir code? It would be ideal to
include it with the Excel report button.
Any ideas?

Thanks,
Louis
 
G

Guest

Open or create a Module and paste in the following function. Change
"C:\testing" to the appropriate drive and folder.

'-----
Function fCreateFolder()

On Error GoTo Err_fCreateFolder

MkDir "C:\testing"

Exit_fCreateFolder:
Exit Function

Err_fCreateFolder:
Select Case Err
Case 0 'insert Errors you wish to ignore here
Resume Next
Case 75 'ignore that the folder is already there error
Resume Next
Case Else 'All other errors will trap
Beep
MsgBox Error$, , "Error in function fCreateFolder"
Resume Exit_fCreateFolder
End Select
Resume 0 'FOR TROUBLESHOOTING
End Function
'------

Then in the On Click event of the Excel report button (assuming that it's
not a standard Switchboard button), put the following code:

fCreateFolder

Now why all the code? If the folder is already there, MkDir will cause an
error as it can't create the folder. Trapping error 75 prevents that problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top