[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『印刷』(soumu)
EXCELファイルで「現在のページを印刷」「カーソルのあるページを印刷」
という設定をしたいのですが、
そういった機能がWORDにしかありません。
EXCELでも同じような事ができますでしょうか?
< 使用 Excel:Excel2007、使用 OS:Windows7 >
Sub test() Dim i As Long Dim r As Long, c As Long Dim myY As Long, myX As Long Dim p As Long ActiveWindow.View = xlPageBreakPreview
r = ActiveCell.Row c = ActiveCell.Column
With ActiveSheet myY = 1 If .HPageBreaks.Count > 0 Then For i = 1 To .HPageBreaks.Count If r < .HPageBreaks(i).Location.Row Then Exit For myY = myY + 1 Next End If myX = 1 If .VPageBreaks.Count > 0 Then For i = 1 To .VPageBreaks.Count If c < .VPageBreaks(i).Location.Column Then Exit For myX = myX + 1 Next End If
If .PageSetup.Order = xlDownThenOver Then p = (.HPageBreaks.Count + 1) * (myX - 1) + myY Else p = (.VPageBreaks.Count + 1) * (myY - 1) + myX End If
.PrintOut From:=p, To:=p
End With
ActiveWindow.View = xlNormalView
End Sub
(マナ) 2014/10/16(木) 19:35
スゴイです(>_<)
思っていた事が完璧にできました!!
感謝しております。。
ありがとうございます。
これで仕事がはかどりそうです!!!!
(soumu) 2014/10/16(木) 19:42
上記のマクロで印刷をかけた所「表示/改ページ」プレビューが「標準」になってしまうんです。
修正ができるようであればご教授願います。
私は全くのマクロ初心者です。
申し訳ございません。
(soumu) 2014/10/16(木) 19:54
Sub test2() Dim v As Long Dim i As Long Dim r As Long, c As Long Dim myY As Long, myX As Long Dim p As Long
v = ActiveWindow.View '★現在の表示 ActiveWindow.View = xlPageBreakPreview '★改ページに変更
r = ActiveCell.Row c = ActiveCell.Column
With ActiveSheet myY = 1 If .HPageBreaks.Count > 0 Then For i = 1 To .HPageBreaks.Count If r < .HPageBreaks(i).Location.Row Then Exit For myY = myY + 1 Next End If myX = 1 If .VPageBreaks.Count > 0 Then For i = 1 To .VPageBreaks.Count If c < .VPageBreaks(i).Location.Column Then Exit For myX = myX + 1 Next End If
If .PageSetup.Order = xlDownThenOver Then p = (.HPageBreaks.Count + 1) * (myX - 1) + myY Else p = (.VPageBreaks.Count + 1) * (myY - 1) + myX End If
.PrintOut From:=p, To:=p
End With
ActiveWindow.View = v '★元の表示に戻す
End Sub
(マナ) 2014/10/16(木) 20:24
(soumu) 2014/10/17(金) 14:37
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.