Bonjour a tous,
Je veux ajuster un code afin de pouvoir choisir le fichier excel que je veux ouvrir sur mon ordinateur.
En ce moment, je dois donner le chemin exacte, mais je veux qu'il m'ouvre l'explorateur afin de choisir un fichier excel.
Comment faire s.v.p?
Voici mon code:
Merci pour votre aide.
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 Dim xlObject As Excel.Application Dim xlWB As Excel.Workbook Set xlObject = New Excel.Application Set xlWB = xlObject.Workbooks.Open("C:\Documents and Settings\xxxxxxx\Desktop\Order Template.xls") 'Open your book here Clipboard.Clear With xlObject.ActiveWorkbook.ActiveSheet .Range("A1:z200").Copy 'Set selection to Copy End With With MSFlexGrid1 .Redraw = False 'Dont draw until the end, so we avoid that flash .Row = 0 'Paste from first cell .Col = 0 .RowSel = .Rows - 1 'Select maximum allowed (your selection shouldnt be greater than this) .ColSel = .Cols - 1 .Clip = Replace(Clipboard.GetText, vbNewLine, vbCr) 'Replace carriage return with the correct one .Col = 1 'Just to remove that blue selection from Flexgrid .Redraw = True 'Now draw End With xlObject.DisplayAlerts = False 'To avoid "Save woorkbook" messagebox 'Close Excel xlWB.Close xlObject.Application.Quit Set xlWB = Nothing Set xlObject = Nothing
Partager