回答編集履歴
3
Word用追加
answer
CHANGED
@@ -8,4 +8,20 @@
|
|
8
8
|
If s > h Then s = h
|
9
9
|
.TextEffect.FontSize = s
|
10
10
|
End With
|
11
|
+
```
|
12
|
+
|
13
|
+
Word用
|
14
|
+
```VBA
|
15
|
+
For Each sh In Sections(1).Headers(wdHeaderFooterFirstPage).Shapes
|
16
|
+
sh.TextFrame.MarginLeft = 0
|
17
|
+
sh.TextFrame.MarginTop = 0
|
18
|
+
sh.TextFrame.MarginRight = 0
|
19
|
+
sh.TextFrame.MarginBottom = 0
|
20
|
+
l = Len(sh.TextFrame.TextRange.Text) - 1
|
21
|
+
w = sh.Width
|
22
|
+
h = sh.Height
|
23
|
+
s = w / l
|
24
|
+
If s > h Then s = h
|
25
|
+
sh.TextFrame.TextRange.Font.Size = s
|
26
|
+
Next
|
11
27
|
```
|
2
縦方向も考慮したコードに修正
answer
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
With Shapes(1)
|
4
4
|
l = Len(.TextEffect.Text)
|
5
5
|
w = .Width - .TextFrame.MarginLeft - .TextFrame.MarginRight
|
6
|
+
h = .Height - .TextFrame.MarginTop - .TextFrame.MarginBottom
|
7
|
+
s = w / l
|
8
|
+
If s > h Then s = h
|
6
|
-
.TextEffect.FontSize =
|
9
|
+
.TextEffect.FontSize = s
|
7
10
|
End With
|
8
11
|
```
|
1
無駄なコードを修正
answer
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
With Shapes(1)
|
4
4
|
l = Len(.TextEffect.Text)
|
5
5
|
w = .Width - .TextFrame.MarginLeft - .TextFrame.MarginRight
|
6
|
-
|
6
|
+
.TextEffect.FontSize = w / l
|
7
7
|
End With
|
8
|
-
|
9
8
|
```
|