cs_kouki69
Messages postés95Date d'inscriptionlundi 27 mars 2006StatutMembreDernière intervention28 août 2015
-
29 juin 2006 à 09:19
domsig
Messages postés125Date d'inscriptionlundi 6 septembre 2004StatutMembreDernière intervention11 mai 2010
-
29 juin 2006 à 10:08
Salut,
Mon programme fait appel a un fichier, appellé PX.OUT. Le problème, c'est que selon les utilisateurs, ce fichier ne se trouve pas à la même place. Donc je souhaite proposer ds le programme un moyen d'indiquer à l'utilisateur où se trouve ce fichier. Une fois celà défini, l'utilisateur n'aura pas à y retoucher. Voici ci-dessous un extrait de ma macro qui fait appel à ce fameux fichier. Dans ce cas, la ligne C:\Eng\Px\WORK\PX.OUT est figée, c'est cette ligne qui devrait être modifiée en fonction de ce que l'utilisateur aura indiqué. Comment puis-je procéder ?
Merci
bigbossnino
Messages postés4Date d'inscriptionjeudi 1 décembre 2005StatutMembreDernière intervention29 juin 2006 29 juin 2006 à 10:02
Si je comprend bien tu veux donner à l'utilisateur le droit de spécifier l'emplacement du fichier.
si c'est e cas tu peux placer un controle du genre FolderBrowserDialog par exemple pour selectionner l'emplacement puis tu recupere le chemin du fichier par la méthode
SelectedPath() du controle que tu as placé,j'espere que ça t'arronge.
domsig
Messages postés125Date d'inscriptionlundi 6 septembre 2004StatutMembreDernière intervention11 mai 2010 29 juin 2006 à 10:08
Salut
en cherchant dans l'aide de vba tu aurais trouvé
Private Sub CommandButton1_Click()
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub