[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『印刷枚数を印字する』(MK)
下記のコードを標準モジュールに入れて、登録したボタンで印刷するようにすることではどうでしょうか。 Sub NumberPrint() MyCopies = Application.InputBox("印刷枚数を入力してください。", "印刷枚数設定", 1, Type:=2) If MyCopies = False Then Exit Sub For i = 1 To MyCopies With ActiveSheet.PageSetup .CenterFooter = MyCopies & "部の内の" & i & "部" End With ActiveWindow.SelectedSheets.PrintOut Copies:=1 Next i With ActiveSheet.PageSetup .CenterFooter = "" 'フッタの設定を削除 End With End Sub
(川野鮎太郎)
WordのVBAは使ったことがなかったのですが、ちょっとチャレンジしてみました。 Sub NumberPrint() MyCopies = InputBox("印刷枚数を入力してください。", "印刷枚数設定") If MyCopies = "" Then Exit Sub For i = 1 To MyCopies ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Selection.TypeText Text:=MyCopies & "部の内の" & i & "部" ActiveDocument.PrintOut Copies:=1 Next i End Sub まず、InputBoxメソッドがないようです。(定かではない) 関数に直しました。 wordにはヘッダーやフッダーがExcelのように3つに分かれていない。 もちろんですが、BookでなくDocument この辺を考慮し記録しながら、チャレンジしました。 取り合えず、動く。です。 (kenbou)
フッタではなくヘッダの右隅に部数のみの印字でいいので良くわからずに自分で加工したのがなにか間違っているのでしょうか?
再再度のご質問申し訳ございませんがご教授ください。
↓自分でアレンジしたものです。
Sub NumberPrint()
MyCopies = InputBox("印刷枚数を入力してください。", "印刷枚数設定") If MyCopies = "" Then Exit Sub For i = 1 To MyCopies ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageheader Selection.TypeText Text:= i ActiveDocument.PrintOut Copies:=1 Next i End Sub
このマクロを設定した後、ヘッダを右寄に設定しました。
本当ですね。確認していなかった。 一回ヘッダーを削除してあげる必要がありそうですね。 (kenbou)
これでいけそうです。 Sub NumberPrint() Dim MyCopies As String, i As Long MyCopies = InputBox("印刷枚数を入力してください。", "印刷枚数設定") If MyCopies = "" Then Exit Sub For i = 1 To MyCopies * 1 ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader Selection.TypeText Text:=i ActiveDocument.PrintOut ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader With Selection .EndOf Unit:=wdParagraph, Extend:=wdExtend .TypeBackspace End With
Next i End Sub (kenbou)
まず、こちらをご覧下さい。 https://www.excel.studio-kazu.jp/wiki/excelboard/#kizon
さて、本題に入ります。 ごめんなさいね。私もWordVBAなんて使わないので。 Sub NumberPrint() Dim MyCopies As String, i As Long MyCopies = InputBox("印刷枚数を入力してください。", "印刷枚数設定") If MyCopies = "" Then Exit Sub For i = 1 To MyCopies With Selection ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader .TypeText Text:=i ActiveDocument.PrintOut ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader .MoveLeft Unit:=wdWord, Count:=Len(i) .Delete Unit:=wdCharacter, Count:=Len(i) End With Next i End Sub これでどうでしょう? (kenbou)
右揃え、フォントサイズの設定をVBAコードで行えば、よいかと思います。 Sub NumberPrint() Dim MyCopies As String, i As Long MyCopies = InputBox("印刷枚数を入力してください。", "印刷枚数設定") If MyCopies = "" Then Exit Sub For i = 1 To MyCopies With Selection ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = "14" .TypeText Text:=i ActiveDocument.PrintOut ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader .MoveLeft Unit:=wdWord, Count:=Len(i) .Delete Unit:=wdCharacter, Count:=Len(i)
End With Next i End Sub (kenbou)
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.