質問編集履歴
4
具体的なこと記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -232,6 +232,8 @@
|
|
232
232
|
|
233
233
|
いろいろ調べてみたのですが改善されず困っております。
|
234
234
|
|
235
|
+
具体的には調べたのですが、エラー箇所から進めず困っています。
|
236
|
+
|
235
237
|
|
236
238
|
|
237
239
|
### 補足情報(FW/ツールのバージョンなど)
|
3
エラーの追記をしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -206,7 +206,7 @@
|
|
206
206
|
|
207
207
|
```
|
208
208
|
|
209
|
-
エラー
|
209
|
+
コンパイルエラー ユーザー定義型は定義されていません。
|
210
210
|
|
211
211
|
```
|
212
212
|
|
@@ -214,6 +214,8 @@
|
|
214
214
|
|
215
215
|
### 該当のソースコード
|
216
216
|
|
217
|
+
R As Cells
|
218
|
+
|
217
219
|
|
218
220
|
|
219
221
|
```ここに言語名を入力
|
2
本文に記載してしまったコードを削除してCODEにうつしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,280 +202,6 @@
|
|
202
202
|
|
203
203
|
|
204
204
|
|
205
|
-
わたしが書いたコードは
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
Option Explicit
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
Sub sendmail()
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
Dim ws As Worksheet
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
Set ws = ThisWorkbook.Sheets("mail")
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
Dim OutApp As Outlook.Application
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
Set OutApp = New Outlook.Application
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
Dim R As Long, lastrow As Long
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
lastrow = ws.Cells(2, 1).End(xlDown).Row
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
For R = 3 To lastrow
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
Dim OutMail As Outlook.MailItem
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
Set OutMail = OutApp.CreateItem(olMailItem)
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
Dim BodyOfMail As String
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
BodyOfMail = CreateBodyOfMail(ws, R)
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
'PDFファイル名生成
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
Dim R As Cells, ws As Object, dt As Variant
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
Set R = Cells(3, 7)
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
Set ws = CreateObject("WScript.shell")
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
dt = ws.SpecialFolders("Desktop") & "\" & "返信.pdf"
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
With OutMail
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
.SendUsingAccount = Session.Accounts(aaaaa@aaa.com)
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
.To = ws.Cells(R, 5).Value
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
.CC = ws.Cells(R, 6).Value & bbb@bbb.com & ccc@ccc.com & ddd@ddd.com
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
.subject = Replace(ws.Cells(2, 10).Value, "コード", ws.Cells(R, 3).Value, "都道府県", ws.Cells(R, 2).Value)
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
.body = BodyOfMail
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
.Attachments.Add dt & " .pdf"
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
End With
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
OutMail.Save
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
Set OutMail = Nothing
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
Next R
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
End Sub
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
Function CreateBodyOfMail(ws As Worksheet, R As Long) As String
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
Dim shimei As String, link As String
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
shimei = ws.Cells(R, 4).Value
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
shisetsu = ws.Cells(R, 2).Value
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
Dim subject As String
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
subject = ws.Cells(2, 2).Value
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
subject = Replace(subject, "都道府県", todou)
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
subject = Replace(subject, "コード", code)
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
Dim body As String
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
body = ws.Cells(3, 10).Value
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
body = Replace(body, "名前", shimei)
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
body = Replace(body, "都道府県", todou)
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
body = body & vbCrLf
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
CreateBodyOfMail = body
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
End Function
|
478
|
-
|
479
205
|
|
480
206
|
|
481
207
|
```
|
1
codeに記載いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,184 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
Option Explicit
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
Sub sendmail()
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
Dim ws As Worksheet
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
Set ws = ThisWorkbook.Sheets("mail")
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
Dim OutApp As Outlook.Application
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Set OutApp = New Outlook.Application
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
Dim R As Long, lastrow As Long
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
lastrow = ws.Cells(2, 1).End(xlDown).Row
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
For R = 3 To lastrow
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Dim OutMail As Outlook.MailItem
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Set OutMail = OutApp.CreateItem(olMailItem)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
Dim BodyOfMail As String
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
BodyOfMail = CreateBodyOfMail(ws, R)
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
'PDFファイル名生成
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Dim R As Cells, ws As Object, dt As Variant
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
Set R = Cells(3, 7)
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
Set ws = CreateObject("WScript.shell")
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
dt = ws.SpecialFolders("Desktop") & "\" & "返信.pdf"
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
With OutMail
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
.SendUsingAccount = Session.Accounts(aaaaa@aaa.com)
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
.To = ws.Cells(R, 5).Value
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
.CC = ws.Cells(R, 6).Value & bbb@bbb.com & ccc@ccc.com & ddd@ddd.com
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
.subject = Replace(ws.Cells(2, 10).Value, "コード", ws.Cells(R, 3).Value, "都道府県", ws.Cells(R, 2).Value)
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
.body = BodyOfMail
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
.Attachments.Add dt & " .pdf"
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
End With
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
OutMail.Save
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
Set OutMail = Nothing
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
Next R
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
End Sub
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
Function CreateBodyOfMail(ws As Worksheet, R As Long) As String
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
Dim shimei As String, link As String
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
shimei = ws.Cells(R, 4).Value
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
shisetsu = ws.Cells(R, 2).Value
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
Dim subject As String
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
subject = ws.Cells(2, 2).Value
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
subject = Replace(subject, "都道府県", todou)
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
subject = Replace(subject, "コード", code)
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
Dim body As String
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
body = ws.Cells(3, 10).Value
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
body = Replace(body, "名前", shimei)
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
body = Replace(body, "都道府県", todou)
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
body = body & vbCrLf
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
CreateBodyOfMail = body
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
End Function
|
180
|
+
|
1
|
-
### 前提・実現したいこと
|
181
|
+
```### 前提・実現したいこと
|
2
182
|
|
3
183
|
|
4
184
|
|