C
Chris Freeman
Hello,
Again, I'm a kind of advanced using Access in general, but a newbie to VBA
coding. I want to export a file to text, then open the file exported using
call shell to notepad. I can export the file fine, and I can open
Notepad.exe, but the file name inserted in the open command seems to cause
failure. This is what I have coded so far:
Dim Filename As String
Dim DataDir As String
Dim NP As String
On Error GoTo mdoExport_CSV_Err
'need to determine if a preferred file save path can be entered here
DataDir = CurDir
Filename = Forms!frm_Export_To_TXT.Combo0
DoCmd.TransferText acExportDelim, "", Forms!frm_Export_To_TXT.Combo0,
Forms!frm_Export_To_TXT.Combo0 & ".txt", False, ""
DoCmd.Close acForm, "frm_Export_To_TXT"
Filename = DataDir & "\" & Filename & ".txt"
'open notepad. determine method to open file
NP = "C:\WINDOWS\system32\notepad.exe"
Call Shell(NP & Filename, vbNormalFocus)
So far it all works individually, and all parameters are correct. Pathname
for the FileName opens the file properly on its own, but using NP and
FileName together causes error.
What's the correct Shell command string I should use?
Thanks in advance
Again, I'm a kind of advanced using Access in general, but a newbie to VBA
coding. I want to export a file to text, then open the file exported using
call shell to notepad. I can export the file fine, and I can open
Notepad.exe, but the file name inserted in the open command seems to cause
failure. This is what I have coded so far:
Dim Filename As String
Dim DataDir As String
Dim NP As String
On Error GoTo mdoExport_CSV_Err
'need to determine if a preferred file save path can be entered here
DataDir = CurDir
Filename = Forms!frm_Export_To_TXT.Combo0
DoCmd.TransferText acExportDelim, "", Forms!frm_Export_To_TXT.Combo0,
Forms!frm_Export_To_TXT.Combo0 & ".txt", False, ""
DoCmd.Close acForm, "frm_Export_To_TXT"
Filename = DataDir & "\" & Filename & ".txt"
'open notepad. determine method to open file
NP = "C:\WINDOWS\system32\notepad.exe"
Call Shell(NP & Filename, vbNormalFocus)
So far it all works individually, and all parameters are correct. Pathname
for the FileName opens the file properly on its own, but using NP and
FileName together causes error.
What's the correct Shell command string I should use?
Thanks in advance