投稿日 | : 2004/12/24(Fri) 15:20 |
投稿者 | : ごん |
Eメール | : |
URL | : |
タイトル | : Re^4: 10.5ポイント以下の設定でエラー |
> エラーが発生するのが確認できる最低限のコードを投稿して下さい。
> (ペーストするだけで動く)
> 部分的なコードを投稿してもらっても同じ状態で確認できないので!!
ご多忙のところすみません。
Sub testA()
Dim myAppOpen As Boolean
'
Dim NumChar As Integer
Dim NumRaw As Integer
Dim Xfont_name As String
Dim Xfont_size As Integer
Dim ret
'
Xfont_name = "MS 明朝"
Xfont_size = 9
NumChar = 59
NumRaw = 58
On Error GoTo ErrRtn
Set DocApp = GetObject(, "Word.Application")
myAppOpen = True
'
MacroContinue:
' Wordのインスタンスが作成されていなかったら作成する
If myAppOpen = False Then
Set DocApp = CreateObject("Word.Application")
End If
'
On Error GoTo 0
Set DocWs = DocApp.Documents.Add
DocApp.Visible = True 'False
'
'ドキュメント操作
'
DocWs.Content.Font.Name = Xfont_name 'フォント設定
DocWs.Content.Font.Size = Xfont_size 'フォントサイズ設定
DocWs.ActiveWindow.View.Zoom.Percentage = 100 '拡大率
'
With DocWs.Sections(1).PageSetup 'ページ設定
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = MillimetersToPoints(25) 'lparam(3)) 25
.BottomMargin = MillimetersToPoints(20) 'lparam(4)) '20
.LeftMargin = MillimetersToPoints(20) 'lparam(1)) '20
.RightMargin = MillimetersToPoints(20) 'lparam(2)) '20
.Gutter = MillimetersToPoints(0)
.HeaderDistance = MillimetersToPoints(15)
.FooterDistance = MillimetersToPoints(17.5)
.PageWidth = MillimetersToPoints(210) 'A4縦
.PageHeight = MillimetersToPoints(297)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft '綴じ代
.CharsLine = NumChar
.LinesPage = NumRaw
.LayoutMode = wdLayoutModeGrid 'wdLayoutModeDefault
ret = MsgBox("正常終了")
End With
DocApp.Quit
'ワード解放
Set DocWs = Nothing
Set DocApp = Nothing
End
'
ErrRtn:
' ActiveXコンポーネントはオブジェクトを作成できません
If Err.Number = 429 Then
myAppOpen = False
Resume MacroContinue
End If
End Sub