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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Private Sub SimpleButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton4.Click
Dim appExcel As Excel.Application 'Declaration Application Excel'
Dim xls As Excel.Workbook 'Declaraton Classeur Excel'
Dim wsExcel As Excel.Worksheet 'Feuille Excel'
Dim codeaidant As String
appExcel = CType(CreateObject("Excel.Application"), Excel.Application)
appExcel.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable
Dim patht As String = appExcel.LibraryPath.Replace("LIBRARY", "XLSTART") 'copie du codeaidant'
appExcel.Workbooks.Open(appExcel.LibraryPath & "\Builder5.xlam") 'Ouvre la macro complementaire Builder5.xlam'
appExcel.Workbooks("Builder5.xlam").RunAutoMacros(1)
xls = appExcel.Workbooks.Open(My.Settings.fexcel, 0, False, 5, "", "", False, Excel.XlPlatform.xlWindows, "", True, False, 0, True, False, False)
'\\sfich01\Public\Report One\Tableaux de bords\Compétences.xlsm
'wsExcel correspond à la première feuille du fichier
'worksheets(1) correspond à la feuille 1 du fichier Excel'
wsExcel = xls.Worksheets(1)
If typedemande.TrimEnd = "I" Then
codeaidant = divers.formatecode(code, divers.strtaillecodeaidant)
Else
codeaidant = ""
End If
'Import de données'
appExcel.Visible = True
xls.Worksheets(1).range("B3").Value = codeaidant
appExcel.Run(xls.Name & "!Feuil1.MAJClasseur")
'lancement de la macro dans le fichier excel ouvert'
On Error Resume Next
If appExcel.Version < "12.0" Then
appExcel.Run("Builder5.xla!CustomMAJ5", "workbook")
If Err.Number <> 0 Then
appExcel.Run("Viewer5.xla!CustomMAJV5", "workbook")
End If
Else
appExcel.Run("Builder5.xlam!CustomMAJ5", "workbook")
If Err.Number <> 0 Then
appExcel.Run("Viewer5.xlam!CustomMAJV5", "workbook")
End If
End If
End Sub |
Partager