Button to copy/open an xls file (1 Viewer)

petrikos

New member
Local time
Tomorrow, 00:02
Joined
Oct 15, 2021
Messages
1
Hello everyone.
I don't know anything about VBA and I need someone to help me with my situation.

I have a button that creates a folder named by the value of the first field which is unique. If it is already created, the button opens it.

Now I need a button that copies an xls file from another location to the above folder or opens it if it is already copied.

Below is the code of the folder creation button to help (it may not be perfect but it works):
Private Sub command81_Click()

Const FOLDER_EXISTS = 75
Dim strFolderPath As String
strFolderPath = "c:\data files\praktor\" & Me.[AA]

On Error Resume Next
MkDir "c:\data files\praktor"
Err.Clear
MkDir "c:\data files\praktor\"
Err.Clear
MkDir strFolderPath
Select Case Err.Number
Case 0
' no error
Case FOLDER_EXISTS
' folder exists so open it
Application.FollowHyperlink strFolderPath
Case Else
' unknown error so inform user
MsgBox Err.Description, vbExclamation, "Error"
End Select

End Sub


Thank you
 

Users who are viewing this thread

Top Bottom