Hi, Being new to VBA, the examples found so far on how to browse for a file and select it have been too complicated for me to use them, so I was wondering if there was an easy way to do it.
This is what I have managed so far, it lets you type in the path and filename;
Const BoxTitle = "Provide MSC Filename"
Dim MSCFileName As String
MSCFileName = InputBox("Enter MSC File Name including full path eg C:\Documents and Settings\Administrator\My Documents\20041103\MSC_031104_0039.dat", BoxTitle)
Answer = MsgBox("Load " + MSCFileName, _
vbOKCancel, "Confirm MSC load")
If Answer = vbCancel Then Exit Sub ' the macro ends if the user selects the CANCEL-button
FileCopy Source:=MSCFileName, destination:="C:\MSC.txt"
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE MSC_load.* FROM MSC_load"
DoCmd.TransferText acImportFixed, "MSC_ddmmyy_ssss Import Specification", "MSC_Load", "C:\MSC.txt", False, ""
[script continues on]
This is what I have managed so far, it lets you type in the path and filename;
Const BoxTitle = "Provide MSC Filename"
Dim MSCFileName As String
MSCFileName = InputBox("Enter MSC File Name including full path eg C:\Documents and Settings\Administrator\My Documents\20041103\MSC_031104_0039.dat", BoxTitle)
Answer = MsgBox("Load " + MSCFileName, _
vbOKCancel, "Confirm MSC load")
If Answer = vbCancel Then Exit Sub ' the macro ends if the user selects the CANCEL-button
FileCopy Source:=MSCFileName, destination:="C:\MSC.txt"
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE MSC_load.* FROM MSC_load"
DoCmd.TransferText acImportFixed, "MSC_ddmmyy_ssss Import Specification", "MSC_Load", "C:\MSC.txt", False, ""
[script continues on]