Hey Guys,
I've tried to remove all the unnessesary data from the macro and I haven't tested it so probably it won't work anymore, But you'll get the picture, also I have created a program to setup the shortcuts (shorts.exe) and this creates a macro with button-label and path in it. If someone wants the full version I could send it to you over email.
Code:
Dim swApp As Object
Dim retval As Integer
Dim pathShortcuts(10) As String
Dim labelShortcuts(10) As String
Dim dummy As Integer
Dim bool As Boolean
Sub Init()
Set swApp = CreateObject("SldWorks.Application")
swApp.Visible = True
LaadShortcuts
End Sub
Sub checkdoc()
bool = True
Set swApp = CreateObject("SldWorks.Application")
swApp.Visible = True
Set ModelDoc = swApp.ActiveDoc
If ModelDoc Is Nothing Then
MsgBox ("Geen part geopend")
bool = False
End If
End Sub
Sub LaadShortcuts()
On Error GoTo Error
Close #1
Open "C:\winnt\SWShortcuts.txt" For Input As #1
dummy = 1
While (dummy < 6)
Input #1, labelShortcuts(dummy)
If (Left(labelShortcuts(dummy), 1) <> "/") Then
Input #1, pathShortcuts(dummy)
If (Left(pathShortcuts(dummy), 1) <> "/" And labelShortcuts(dummy) <> "/") Then dummy = dummy + 1
End If
Wend
SetShortcuts
On Error GoTo 0
GoTo skip
Error: shorts
skip:
End Sub
Sub SetShortcuts()
Shortcut1.Caption = labelShortcuts(1)
Shortcut2.Caption = labelShortcuts(2)
Shortcut3.Caption = labelShortcuts(3)
Shortcut4.Caption = labelShortcuts(4)
Shortcut5.Caption = labelShortcuts(5)
End Sub
Sub shorts()
Shell "M:\Solidworks\SW Tools\IMS tools\shorts.exe", vbNormalFocus
End
End Sub
Private Sub Shortcut1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If (Button = 1) Then
On Error GoTo Error
Dim args As String
If (Mid(pathShortcuts(1), 2, 1) = ":") Then
args = ""
retval = swApp.SetCurrentWorkingDirectory(pathShortcuts(1))
retval = swApp.Command(swFileOpen, args)
End If
GoTo skip
End If
If (Button = 2) Then
On Error GoTo Error
If (Mid(pathShortcuts(1), 2, 1) = ":") Then
opdracht = "explorer " + pathShortcuts(1)
Shell opdracht, vbNormalFocus
End If
GoTo skip
End If
Error: MsgBox ("Deze functie werkt alleen in solidworks 2004")
skip:
On Error GoTo 0
End Sub
Grtz, Bouke