cs_Dominike
Messages postés70Date d'inscriptionjeudi 13 février 2003StatutMembreDernière intervention 6 mars 2010
-
13 mai 2008 à 12:53
cs_Dominike
Messages postés70Date d'inscriptionjeudi 13 février 2003StatutMembreDernière intervention 6 mars 2010
-
14 mai 2008 à 01:37
Bonjour à tous !
Je savais que je me lançais dans un projet au-dessus de mes compétences, mais c'est à mon avis comme cela comme apprend.
Bref, après avoir surmonté presque seul la première difficulté, j'ai à anouveau besoin de l'aide de cette brillante communauté.
Je vais tenter d'être le + clair possible.
Je voudrais automatiser des tâches du style :
J'ai des fichiers à rechercher à partir desquels en ajoutant deux ou trois variables, je déclenche certains calculs et macros divers...
J'ai dons un UserForm avec deux combobox et une zone de saisie.
Pour tester la récupération des variables, j'ai réalisé un test qui me renvoi un MsgBox récapitulant mes choix. C'est OK !
Mais je ne parviens pas à réutiliser mes variables dans un autre module du style :
----------------------
Sub MesChoix ()
If Echantillon = 10 Then
MsgBox " On peut lancer la macro correspondant !"
Else
MsgBox " ca ne fonctionne pas !"
End if
End Sub
---------------------
Quelque soit le résultat de ma variable, j'ai toujours le deuxième message.
Voici mes codes prédécents :
1 dans le UserForm
--------------------
Private Sub Editer_Click()
'----------- Déterminationdes variables des deux combobox ---------
Fichier = Choix.List(Choix.ListIndex)
Numero_Rciqt = Rciqt.List(Rciqt.ListIndex)
'------------------------------------------------------------------
Dim DerniereLigne As Integer
DerniereLigne = Range("A100").End(xlUp).Row
Choix.RowSource = "Feuil1!A1:A" & DerniereLigne
End Sub
-----------------------------
Dans le module
-----------------------------
Option Explicit
Dim Numero_Rciqt As Integer
Dim Fichier As String
Dim Echantillon As Integer
Public dossier
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'32-bit API declarations
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Function GetDirectory(Optional Msg) As String
Dim bInfo As BROWSEINFO, path As String, r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = ""
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
x = SHBrowseForFolder(bInfo)
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
GetDirectory = Left(path, pos - 1)
Else
GetDirectory = ""
End If
End Function
Sub File_Openen()
Columns("A:A").Select
Selection.ClearContents
Range("A1").Select
Dim fs, i, namefile, FileNumber, specfichier, nbfiles, r, Srep, folder, ct
dossier = GetDirectory("Choisit un dossier : ")
If dossier <> "" Then
Set fs = Application.FileSearch
With fs
.LookIn = dossier
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
nbfiles = .FoundFiles.Count
For i = 1 To nbfiles
specfichier = .FoundFiles(i)
Range("A" & i) = specfichier
Next i
End If
End With
End If
'-------- Ici j'appelle mon User Form "Choix de fichier" --------
Liste.Show
'----------------------------------------------------------------
End Sub
=========================================
Merci pour votre aide à nouveau !
-Dominike -
cs_Dominike
Messages postés70Date d'inscriptionjeudi 13 février 2003StatutMembreDernière intervention 6 mars 2010 13 mai 2008 à 14:00
Merci pour la réponse rapide.
J'ai essayé déjà, mais à ce moment là, la macro bugue ici :
Private Sub Editer_Click()
'----------- Détermination des variables des deux combobox ---------
Fichier = Choix.List(Choix.ListIndex)
Numero_Rciqt = Rciqt.List(Rciqt.ListIndex)
'----------------------------------------------------------------------
Autre difficulté, l'une des deux variables a un format de type : 1.1 ou 2.2
J'ai du mal ....