将文档添加到数据

时间:2020-07-03 12:23:37

标签: excel vba

我有一份带有相关文件和日期的培训清单。 我想将文档添加到这些培训中,而不在数据库中创建重复项。

即如果我有一个名为A的培训,带有日期并且想要向其中添加文档,我将得到

enter image description here

我写的代码给了我

enter image description here

代码:

Private Sub Sub_Ajout_Mdp_Forma_Click()
    If mode_edition = True Then
        If Me.ListBox_Form_Intern.ListIndex = -1 Then
            MsgBox ("Pour ajouter le mode de preuve veuillez choisir une formation")
        Else
            Set ws = ActiveWorkbook.Worksheets(Personne)
            Nom_Forma = Me.ListBox_Form_Intern.List(Me.ListBox_Form_Intern.ListIndex, 0)
            Date_Forma = Me.ListBox_Form_Intern.List(Me.ListBox_Form_Intern.ListIndex, 1)
            Fin_Col_Forma = ws.Cells(10, 256).End(xlToLeft).Column
            Dim plage As Range
            Set ws = ActiveWorkbook.Worksheets(Personne)
            Set plage = ws.Rows(10)
            Set Trouve = plage.Cells.Find(what:=Nom_Forma)
            If Trouve Is Nothing Then
            Else
                If MsgBox("la formation existe déjà, Voulez vous l'écraser pour ajouter le mode de preuve?", vbYesNo + vbExclamation + vbDefaultButton2, "Titre") = vbYes Then
                    ws.Cells(10, Fin_Col_Forma).Value = Nom_Forma
                    Cells(10, Fin_Col_Forma).Select
                    ws.Activate
                    ws.Cells(11, Fin_Col_Forma).Value = CDate(Date_Forma)
                    repertoire = Application.GetOpenFilename()
                    ws.Cells(12, Fin_Col_Forma) = repertoire
                Else
                    MsgBox (" Vous n'avez pas les droits requis")
                End If
            End If
        End If
    End If
End Sub

我想添加文档而不创建重复的文档,所以删除旧的培训并仅保留我添加的内容

0 个答案:

没有答案