Thema Datum  Von Nutzer Rating
Antwort
26.11.2019 20:44:55 Said
NotSolved
26.11.2019 21:54:35 Mase
NotSolved
26.11.2019 21:56:55 Gast34789
NotSolved
26.11.2019 22:05:23 Gast76631
NotSolved
26.11.2019 22:20:21 Mase
NotSolved
26.11.2019 22:24:58 Gast54865
NotSolved
26.11.2019 22:27:35 Mase
NotSolved
26.11.2019 21:54:35 Gast35790
NotSolved
26.11.2019 22:26:07 Mase
NotSolved
27.11.2019 08:24:47 Gast36201
NotSolved
27.11.2019 08:28:44 Said
NotSolved
Blau Laufzeitfehler "1004".: Anwendungs- oder objektdefinierter Fehler. Ohne Fehlermeldung
27.11.2019 08:53:42 Mase
NotSolved
27.11.2019 08:55:41 Mase
NotSolved
27.11.2019 09:01:52 Mase
NotSolved
27.11.2019 10:03:03 Said
NotSolved

Ansicht des Beitrags:
Von:
Mase
Datum:
27.11.2019 08:53:42
Views:
761
Rating: Antwort:
  Ja
Thema:
Laufzeitfehler "1004".: Anwendungs- oder objektdefinierter Fehler. Ohne Fehlermeldung

Guten Morgen Said,

Du hast eine Referenz auf das Workbook, aber keine auf ein Worksheet.

Versuch mal folgendes:

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
Sub LoopThroughFiles()
    Dim wbk As Workbook
    RootFolder = MacScript("return (path to desktop folder) as String")
   
    If Val(Application.Version) < 15 Then
        scriptstr = "(choose folder with prompt ""Select the folder""" & _
            " default location alias """ & RootFolder & """) as string"
    Else
        scriptstr = "return posix path of (choose folder with prompt ""Select the folder""" & _
            " default location alias """ & RootFolder & """) as string"
    End If
   
    folderPath = MacScript(scriptstr)
    On Error GoTo 0
   
MyFolder = folderPath
MyFile = Dir(MyFolder)
  
    Do While MyFile <> ""
    Set wbk = Workbooks.Open(Filename:=MyFolder & MyFile, Password:="change")
    Workbooks(MyFile).Activate
    Rows("1:1").Select
    Selection.RowHeight = 20
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.AutoFilter
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Font.Bold = False
      
    wbk.Close savechanges:=True
        MyFile = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
 
Sub modLoopThroughFiles()
    Dim wbk As Workbook
    Dim wks As Worksheet
    '
    RootFolder = MacScript("return (path to desktop folder) as String")
   
    If Val(Application.Version) < 15 Then
        scriptstr = "(choose folder with prompt ""Select the folder""" & _
            " default location alias """ & RootFolder & """) as string"
    Else
        scriptstr = "return posix path of (choose folder with prompt ""Select the folder""" & _
            " default location alias """ & RootFolder & """) as string"
    End If
   
    folderPath = MacScript(scriptstr)
    On Error GoTo 0
   
MyFolder = folderPath
MyFile = Dir(MyFolder)
  
    Do While MyFile <> ""
        Set wbk = Workbooks.Open(Filename:=MyFolder & MyFile, Password:="change")
        Set wks = wbk.Worksheets(1)
        With wks
        'Workbooks(MyFile).Activate
        .Rows("1:1").RowHeight = 20
        .Range("A1").Select
        .Range(Selection, Selection.End(xlToRight)).Select
        .Range(Selection, Selection.End(xlDown)).Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Interior
            .Pattern = xlNone
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
        .Range("A1").Select
        .Range(Selection, Selection.End(xlToRight)).Select
        Selection.AutoFilter
        .Range("A2").Select
        .Range(Selection, Selection.End(xlDown)).Select
        Selection.Font.Bold = False
        '
        wbk.Close savechanges:=True
        '
        Set wks = Nothing
        Set wkb = Nothing
        '
        MyFile = Dir
    Loop
    Application.ScreenUpdating = True
End Sub

By the way:

Selection, .Select, brauchst Du bei ~99% der Fälle nicht, da Du Deine Objekte kennst und mit Objektvarfiablen darauf zugreifen kannst.

Das ist ein anderes Thema; können wir aber gesondert nach der Lösung #1004 angehen; wenn Du magst. Ansonsten gibst genug Lektüre im Netz dazu.


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
26.11.2019 20:44:55 Said
NotSolved
26.11.2019 21:54:35 Mase
NotSolved
26.11.2019 21:56:55 Gast34789
NotSolved
26.11.2019 22:05:23 Gast76631
NotSolved
26.11.2019 22:20:21 Mase
NotSolved
26.11.2019 22:24:58 Gast54865
NotSolved
26.11.2019 22:27:35 Mase
NotSolved
26.11.2019 21:54:35 Gast35790
NotSolved
26.11.2019 22:26:07 Mase
NotSolved
27.11.2019 08:24:47 Gast36201
NotSolved
27.11.2019 08:28:44 Said
NotSolved
Blau Laufzeitfehler "1004".: Anwendungs- oder objektdefinierter Fehler. Ohne Fehlermeldung
27.11.2019 08:53:42 Mase
NotSolved
27.11.2019 08:55:41 Mase
NotSolved
27.11.2019 09:01:52 Mase
NotSolved
27.11.2019 10:03:03 Said
NotSolved