トップ回答者
Access VBA Reportのプロパティ設定について

質問
回答
-
ページヘッダ,ページフッタ,詳細といったセクションの高さを変えてその合計を高さとすることは可能です。
#詳細で繰り返しが発生すれば合計の高さが変わりますがOption Compare Database Option Explicit Sub Test() Const width As Double = 567 * 18 Const height As Double = 567 * 11.4 Dim r As Report Set r = Application.CreateReport r.width = width Dim col As New Collection Dim sec As Section Dim sections() As Variant sections = Array(AcSection.acHeader, AcSection.acFooter, AcSection.acPageHeader, AcSection.acPageFooter, AcSection.acGroupLevel1Header, AcSection.acGroupLevel1Footer, AcSection.acGroupLevel2Header, AcSection.acGroupLevel2Footer) Dim hTemp As Double 'ページヘッダ以外の高さの合計 Dim i As Integer For i = LBound(sections) To UBound(sections) Dim e As Long On Error Resume Next Set sec = r.Section(sections(i)) e = Err.Number On Error GoTo 0 If (e = 0) Then If (sec.Visible) Then hTemp = hTemp + sec.height Call col.Add(sections(i)) End If End If Next If (height < hTemp) Then '詳細部の高さがマイナスになってしまう場合 Dim v As Variant For Each v In col Set sec = r.Section(v) sec.height = 0 '詳細以外のセクションの高さを0に Next hTemp = 0 End If Set sec = r.Section(AcSection.acDetail) sec.height = height - hTemp '詳細部の高さを設定 End Sub
個別に明示されていない限りgekkaがフォーラムに投稿したコードにはフォーラム使用条件に基づき「MICROSOFT LIMITED PUBLIC LICENSE」が適用されます。(かなり自由に使ってOK!)
- 回答としてマーク bolbox 2017年8月17日 11:48
すべての返信
-
ページヘッダ,ページフッタ,詳細といったセクションの高さを変えてその合計を高さとすることは可能です。
#詳細で繰り返しが発生すれば合計の高さが変わりますがOption Compare Database Option Explicit Sub Test() Const width As Double = 567 * 18 Const height As Double = 567 * 11.4 Dim r As Report Set r = Application.CreateReport r.width = width Dim col As New Collection Dim sec As Section Dim sections() As Variant sections = Array(AcSection.acHeader, AcSection.acFooter, AcSection.acPageHeader, AcSection.acPageFooter, AcSection.acGroupLevel1Header, AcSection.acGroupLevel1Footer, AcSection.acGroupLevel2Header, AcSection.acGroupLevel2Footer) Dim hTemp As Double 'ページヘッダ以外の高さの合計 Dim i As Integer For i = LBound(sections) To UBound(sections) Dim e As Long On Error Resume Next Set sec = r.Section(sections(i)) e = Err.Number On Error GoTo 0 If (e = 0) Then If (sec.Visible) Then hTemp = hTemp + sec.height Call col.Add(sections(i)) End If End If Next If (height < hTemp) Then '詳細部の高さがマイナスになってしまう場合 Dim v As Variant For Each v In col Set sec = r.Section(v) sec.height = 0 '詳細以外のセクションの高さを0に Next hTemp = 0 End If Set sec = r.Section(AcSection.acDetail) sec.height = height - hTemp '詳細部の高さを設定 End Sub
個別に明示されていない限りgekkaがフォーラムに投稿したコードにはフォーラム使用条件に基づき「MICROSOFT LIMITED PUBLIC LICENSE」が適用されます。(かなり自由に使ってOK!)
- 回答としてマーク bolbox 2017年8月17日 11:48