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

回答編集履歴

3

Word用追加

2016/09/09 07:55

投稿

ttyp03
ttyp03

スコア17002

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

縦方向も考慮したコードに修正

2016/09/09 07:55

投稿

ttyp03
ttyp03

スコア17002

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 = w / l
9
+ .TextEffect.FontSize = s
7
10
  End With
8
11
  ```

1

無駄なコードを修正

2016/09/08 05:38

投稿

ttyp03
ttyp03

スコア17002

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
- Shapes(1).TextEffect.FontSize = w / l
6
+ .TextEffect.FontSize = w / l
7
7
  End With
8
-
9
8
  ```