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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| Private Sub cmdAddLetter_Click()
Dim xlApp As Object
Dim xlWb As Object
Dim xlSh As Object
Dim dlg As FileDialog
Dim stFile As String
Dim i As Integer
Dim bmks As Bookmarks
Dim nom As Object
Set xlApp = CreateObject("excel.application")
With ActiveDocument.worksheets
Set xlSh = xlWb.sheets(1)
End With
Debug.Print xlSh.usedrange.Rows.Count
For i = 1 To xlSh.usedrange.Rows.Count
Debug.Print i
Set bmRange = ActiveDocument.Bookmarks("signet").Range
bmRange.Text = nom.Value
Next i
Set xlSh = Nothing
Set xlWb = Nothing
Set xlApp = Nothing
xlApp.Quit
End Sub
Private Sub CommandButton2_Click()
End Sub
Private Sub UserForm_Initialize()
On Error Resume Next
Dim xlApp As Object
Dim xlWb As Object
Dim xlSh As Object
Dim dlg As FileDialog
Dim stFile As String
Dim i As Integer
Dim bmks As Bookmarks
Dim bmRange As Range
Dim nom As Object
Set dlg = Word.Application.FileDialog(msoFileDialogFilePicker)
With dlg
.InitialFileName = "*.xls"
.Show
End With
stFile = dlg.SelectedItems(1)
Debug.Print stFile
Set xlApp = CreateObject("excel.application")
Set xlWb = xlApp.workbooks.Open(stFile)
Set xlSh = xlWb.sheets(1)
Debug.Print xlSh.usedrange.Rows.Count
For i = 1 To xlSh.usedrange.Rows.Count
Debug.Print i
Me.ComboBox1.AddItem (xlSh.Cells(i, 1))
If Me.ComboBox1.Value = (xlSh.Cells(i, 1)) Then
nom = xlSh.Cells(i, 2).Value
End If
Debug.Print xlSh.Cells(i, 2)
Next i
End Sub |
Partager