01 | Attribute VB_Name = "mod1Oefeningen" |
02 |
03 | Option Explicit |
04 |
05 | Sub Oefening1() |
06 | |
07 | Dim wbWerkboek As Workbook |
08 | Dim strBestand As String |
09 | |
10 | strBestand = ActiveWorkbook.Path & "\Bronnen\Werkmap 1.xlsx" |
11 | |
12 | Set wbWerkboek = Workbooks.Open(strBestand) |
13 | |
14 | End Sub |
15 |
16 | Sub Oefening2() |
17 |
18 | On Error GoTo FoutAfhandelaar |
19 |
20 | Dim wbWerkboek As Workbook |
21 | Dim strBestand As String |
22 | |
23 | strBestand = ActiveWorkbook.Path & "\Bronnen\Werkmap 4.xlsx" |
24 | |
25 | Set wbWerkboek = Workbooks.Open(strBestand) |
26 | |
27 | Exit Sub |
28 | |
29 | FoutAfhandelaar: |
30 | |
31 | If Err.Number = 1004 Then |
32 | MsgBox "Het bestand: " & strBestand & " is niet gevonden!" , vbCritical |
33 | End If |
34 |
35 | End Sub |
36 |
37 | Sub Oefening3() |
38 |
39 | Dim wbWerkboek As Workbook |
40 | Dim strBestand As String |
41 | |
42 | strBestand = ActiveWorkbook.Path & "\Bronnen\Werkmap 4.xlsx" |
43 | |
44 | If Dir(strBestand) = "" Then |
45 | MsgBox "Het bestand: " & strBestand & " is niet gevonden!" , vbCritical |
46 | Else |
47 | Set wbWerkboek = Workbooks.Open(strBestand) |
48 | End If |
49 |
50 | End Sub |
Download hier het bestand.