Call Shell

  • Thread starter Thread starter Bre-x
  • Start date Start date
B

Bre-x

Good Morning All,

Example
To open this file C:\mydir\myfile.txt I will use the following function

TS = "C;\Windows\Notepad.exe" & " " & "C:\mydir\myfile.txt"
Call Shell(TS, 1)

What about if I don't know the file extension?
Like C:\mydir\myfile.ttt or C:\mydir\myfile.spv

Thank for you help

Regards,

Bre-x
 
To open this file C:\mydir\myfile.txt I will use the following function
TS = "C;\Windows\Notepad.exe" & " " & "C:\mydir\myfile.txt"
Call Shell(TS, 1)

What about if I don't know the file extension?
Like C:\mydir\myfile.ttt or C:\mydir\myfile.spv

You can use the code at http://www.mvps.org/access/api/api0001.htm to retrieve
the full filename and assign it to "TS" in place of your existing file
reference.
 
Hi Bruce,
Thanks for answering my question.
I could use that approch but, I am talking about at least 10 directories and
at least 200 files on each directory.

I need to find a way to do it automatically.

Regards,

Bre-x
 
Thanks for answering my question.
I could use that approch but, I am talking about at least 10 directories and
at least 200 files on each directory.

I need to find a way to do it automatically.

Maybe you should explain more fully what it is you are trying to do. I don't
suspect that you are trying to open all the files in all of those directories,
so there must be something that will identify which file it is that you want to
open. It would be very helpful if you provided the actual code that you are
using.
 
Hi Bruce,

We have an MS Access application for the CNC Machine Department
They use it to keep tranck of their CAD Files.

I have a function that allows them to open a CAD File by double clicking the
record by launching a expecific software wich shortcut i have it on a
table called "Local_Settings"

But they have upgrade their CAD Software now we have files with MC8, MC9 and
MC10 file extencions.

The function works fine when they open a file with the MC8 extension but as
you can see they have 3 diferent file extensions now.


Function ShowMasterCam()
On Error GoTo Err_ShowMasterCam
Dim FName As String, TP As String
FName = Screen.ActiveForm.Name
Select Case FName
Case "Main"
TP = [Forms]![Main]![MainSub].[Form]![Path] & ".mc8"
If ExitsFile(TP) = "True" Then
GoTo TL
Else
GoTo TR
End If
Case "Tickets"
TP = Forms![Tickets]![TicketsLines].Form![Path] & "\" &
Forms![Tickets]![TicketsLines].Form![MachineCode] &
Forms![Tickets]![TicketsLines].Form![Program] & ".mc8"
If ExitsFile(TP) = "True" Then
GoTo TL
Else
GoTo TR
End If
Case Else
Exit Function
End Select

TL:
TShell = DLookup("[Value]", "Local_Settings", "[ID]=" & 4) & " " & TP
Call Shell(TShell, 1)
Exit Function

TR:
Responce = MsgBox("File not found or non existing", vbCritical +
vbOKOnly, CiaName())
Exit Function
Exit_ShowMasterCam:
Exit Function
Err_ShowMasterCam:
If Err.Number = 2475 Or Err.Number = 2465 Then
Responce = MsgBox("Wrong Window", vbCritical + vbOKOnly, CiaName())
Exit Function
Else
MsgBox Err.Description & " Error Number: " & Err.Number
Resume Exit_ShowMasterCam
End If
End Function
 
Response below.
We have an MS Access application for the CNC Machine Department
They use it to keep tranck of their CAD Files.

I have a function that allows them to open a CAD File by double clicking the
record by launching a expecific software wich shortcut i have it on a
table called "Local_Settings"

But they have upgrade their CAD Software now we have files with MC8, MC9 and
MC10 file extencions.

The function works fine when they open a file with the MC8 extension but as
you can see they have 3 diferent file extensions now.


Function ShowMasterCam()
On Error GoTo Err_ShowMasterCam
Dim FName As String, TP As String
FName = Screen.ActiveForm.Name
Select Case FName
Case "Main"
TP = [Forms]![Main]![MainSub].[Form]![Path] & ".mc8"
If ExitsFile(TP) = "True" Then
GoTo TL
Else
GoTo TR
End If
Case "Tickets"
TP = Forms![Tickets]![TicketsLines].Form![Path] & "\" &
Forms![Tickets]![TicketsLines].Form![MachineCode] &
Forms![Tickets]![TicketsLines].Form![Program] & ".mc8"
If ExitsFile(TP) = "True" Then
GoTo TL
Else
GoTo TR
End If
Case Else
Exit Function
End Select

TL:
TShell = DLookup("[Value]", "Local_Settings", "[ID]=" & 4) & " " & TP
Call Shell(TShell, 1)
Exit Function

TR:
Responce = MsgBox("File not found or non existing", vbCritical +
vbOKOnly, CiaName())
Exit Function
Exit_ShowMasterCam:
Exit Function
Err_ShowMasterCam:
If Err.Number = 2475 Or Err.Number = 2465 Then
Responce = MsgBox("Wrong Window", vbCritical + vbOKOnly, CiaName())
Exit Function
Else
MsgBox Err.Description & " Error Number: " & Err.Number
Resume Exit_ShowMasterCam
End If
End Function

It appears that your issue is related to shelling out to the proper version of
the CAD software when opening a drawing. I assume that each file extension is
associated with the appurtenant version of the CAD software, so you might
consider using the "ShellExecute()" api call to open the appropriate version of
the software automatically - all you will need is the path and filename for the
drawing that you want to open. You can find some code for this at The Access
Web, as well:

API: Start an app with ShellExecute
http://www.mvps.org/access/api/api0018.htm

If I have missed the mark, let me know.
 
Back
Top