hello, I have this macro (found on the net) to import files, since it is not within my capabilities and skills, I ask if anyone can correct it for me. what I would like to do is this: in addition to selecting the file, I would also like to choose the directory (the line is = PathName = "c:\mach3\quilting") I have 7 different working directories and I would like to choose the directory where to download the file. is it possible to change it? Is there anyone who can help me? I hope I explained myself and I thank anyone who can help me
I attach macros
'=========================================================
' Pattern File selection
'=========================================================
Option Explicit
Global fileName As String
Global fileExitCode As Integer
Global fileExtension As String
Declare Function GetDlgCtrlID Lib "User32" ( ByVal hwndCtl As Long ) As Long
Declare Function DlgDirListA Lib "User32" ( ByVal hDlg As Long, ByVal PathSpec As String, ByVal nIDListBox As Long, ByVal nIDStatic As Long, ByVal nFileType As Long ) As Long
Sub Main
fileExtension = "*.tap" ' the extension we are looking for
Call GetFileName ' as user for file name
If Len(fileName) = 0 Then ' if 0 len cancel
fileExitCode = 1
End If
If fileExitCode = 0 Then
MsgBox("The Selected Pattern is: " & fileName)
SavePatternName ' save the name for others
SetUserLabel(8, fileName) ' Set the user label for all to see
Else
MsgBox("No Pattern Selected")
End If
End Sub
Sub GetFileName
Dim MyList$()
Begin Dialog PatternDlg 60, 60, 180, 225, "Quilt Pattern Select", .DlgFunc
TextBox 10, 15, 150, 12, .Text1
Text 30, 45, 150, 9, "", .Path
Text 15, 5, 150, 9, "Selection Criteria"
Text 35, 35, 150, 9, "Selected Pattern"
ListBox 25, 60, 125, 140, MyList(), .List1, 2 ' Sort
CancelButton 42, 203, 40, 12
OKButton 90, 203, 40, 12
End Dialog
Dim frame As PatternDlg
Dialog frame
End Sub
Function DlgFunc( controlID As String, action As Integer, suppValue As Integer )
Static nPathID As Integer
Static PathName As String
Static nListID As Integer
Static FileSpec As String
Select Case action
Case 1 ' Initialize
PathName = "c:\mach3\quilting"
DlgText "Text1", PathName & "\" & fileExtension
nListID = GetDlgCtrlID( DlgControlHWND("List1") )
nPathID = GetDlgCtrlID( DlgControlHWND("Path") )
DlgDirListA DlgHWND, DlgText("Text1"), nListID, nPathID, &h10
Case 2 ' Click
If controlID = "Cancel" Then ' Cancel Button
fileName=""
fileExitCode=1
DlgFunc = 0
Exit Function
End If
If controlID = "OK" Then ' OK Button
DlgDirListA DlgHWND, DlgText("Text1"), nListID, nPathID, &h10
PathName = DlgText("Path")
fileExitCode=0
DlgFunc = 0
Else
FileSpec = DlgText("List1")
If Left( FileSpec, 1 ) = "[" Then ' FileSpec is a directory
PathName = Mid( FileSpec, 2, Len(FileSpec)-2 )
DlgDirListA DlgHWND, PathName & "\" & fileExtension, nListID, nPathID, &h10
PathName = DlgText("Path")
If Right( PathName, 1 ) <> "\" Then
PathName = PathName & "\"
End If
DlgText "Text1", PathName & fileExtension
Exit Function
End If
If Right( PathName, 1 ) <> "\" Then
PathName = PathName & "\"
End If
fileName = PathName & DlgText("List1")
DlgText "Path", fileName
End If
End Select
End Function
Sub SavePatternName
'
' save the filename in Var(1-x) Len in 0
'
Dim I
Call SetVar(0,Len(fileName))
For I = 1 To Len(fileName)
Call SetVar(I,Asc(Mid(fileName,I,1)))
Next I
End Sub
Sub GetPatternName
'
' get the filename in Var(1-x) Len in 0
'
Dim lenStr, I, MyStr
lenStr = GetVar(0)
MyStr=""
For I = 1 To lenStr
MyStr=MyStr & Chr(GetVar(I))
Next I
fileName=MyStr
End Sub
Main