teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

修正

2021/01/19 00:15

投稿

radames1000
radames1000

スコア1925

answer CHANGED
@@ -1,46 +1,50 @@
1
- ざっくりですが。
2
1
  ```vba
3
2
  Option Explicit
4
3
 
5
4
  Sub showTargetImage()
6
5
 
7
6
  Dim myPath, buf As String
7
+ Dim myFile() As String
8
- Dim lngLeft As Long, lngTop As Long
8
+ Dim lngLeft As Long
9
9
  Dim i As Long, j As Long
10
+ Dim cnt() As Long
10
11
 
11
12
  myPath = ThisWorkbook.Path
12
13
 
13
14
  buf = Dir(Path + "\target\" + "*.jpg")
15
+ Do While buf <> ""
16
+ j = j + 1
17
+ ReDim Preserve myFile(j)
18
+ myFile(j) = buf
19
+ buf = Dir()
20
+ Loop
14
21
 
22
+ ReDim cnt(6)
23
+ cnt(1) = 1
24
+ For i = 2 To 5
25
+ cnt(i) = Int(j * 0.2 * (i - 1))
26
+ Next
27
+ cnt(6) = j
28
+
15
29
  lngLeft = 296
30
+ For i = 1 To 6
31
+ With Sheets("view").Pictures.Insert(myPath & "\target\" & myFile(cnt(i)))
32
+
16
- lngTop = 106.875
33
+ .Top = 106.875
17
-
18
- i = 1
19
- j = 1
20
- Do While buf <> ""
21
- If i > 6 Then
22
- i = 1
23
- j = j + 1
24
- lngLeft = 296
34
+ .Left = lngLeft
25
- End If
26
- With Sheets("view").Pictures.Insert(myPath + "\target\" + buf)
27
35
 
28
- .Top = lngTop * j
29
- .Left = lngLeft
30
-
31
- .Width = 53
36
+ .Width = 53
32
- .Height = 30
37
+ .Height = 30
33
-
34
- lngLeft = lngLeft + 53 + 5
35
-
36
- Application.Wait [Now()] + 350 / 86400000
37
38
 
38
- End With
39
- i = i + 1
39
+ lngLeft = lngLeft + 53 + 5
40
40
 
41
+ Application.Wait [Now()] + 350 / 86400000
42
+
41
- buf = Dir()
43
+ End With
42
- Loop
44
+ Next
43
45
 
44
46
  End Sub
45
-
46
- ```
47
+ ```
48
+ 「いい感じ」「まんべんなく」「なんとなく」という表現では
49
+ 何がしたいかわかりません。
50
+ 相手に伝わるようにしてください。