Bonjour,

J'utilise un code VBA qui me permet d'ouvrir un fichier de type rqy. Il m'ouvre alors les résultats de la requête dans un fichier excel qui se nomme classeur2 par défault. J'aimerai pouvoir manipuler ce classeur en vba mais je ne sais pas comment me positionner dessus car le fichier n'est pas enregistrer donc je ne peut pas me positionner dessus en indiquant le chemin d'accès.

Voila si quelqu’un aurait une solution.

Code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
 
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 
 
Sub bouton1_cliquer()
 
    Const SW_SHOWNORMAL = 1
    Dim hwnd As Long
    Dim Fich As String
 
    Fich = "d:\U710464\Bureau\Mission3\BDCF\BDCAmontExtractAll.dqy"
 
 
    hwnd = FindWindow(vbNullString, Application.Caption)
    ShellExecute hwnd, "open", Fich, vbNullString, vbNullString, SW_SHOWNORMAL
 
 
    Sheets.Add.Move After:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = "lolol"
 
 
End Sub
Merci