使用条件
ExcelとPublisherが入っていること。
Office 365 Solo
Office Professional
パーソナル、ホーム&ビジネスなど、Publisherが含まれていないものはPublisherを追加しないと使えない
英語
ところで方眼紙って英語でどういうのか
graph paper
squared paper
section paper(England)
paper ruled into 10‐millimeter squares 10mm方眼
このように複数の表現があり、イギリスだけで使う表現があるようだ。
Excel方眼は正確には無理
まずパソコン以前に印刷というものがインチなどを使っており、メートル法を使っていない。
パソコンもこれを反映している。
これがmm単位の方眼が作れない理由。
さらに1 Pixcelの幅が縦と横で違う。
表記はメートル法でもそれは表示のみなのである。
印刷で使われる単位
印刷やデザインで使う単位の基礎知識
ポイント(pt)1ポイント= DTPポイント:0.3528mm(JIS規格:0.3514でmm)
パイカ(p) 欧文活字の大きさのひとつです。12ptの活字に相当します。
歯(H)1H=0.25mm
級(「Q」or「q」)1級=0.25mmです。
ピクセル(px)コンピューターで画像を扱う時の最少単位(ドット)
「dip」や「ppi」 1インチ25.4mmの中にドット(ピクセル)が何個含まれているかを示した単位
PCのディスプレイは640*400など縦と横に含まれるドットは違うため、1ピクセルの幅が違うことになる。またExcelはフォントやフォントサイズによっても違うようだ。
フォントとフォントサイズの指定
プロポーショナルフォントを避ける。
MS ゴシック 日本語 11
できるだけ大きくしてポイントとピクセルの換算値を求める
セルの縦と横の比 - やむえむのExcel VBAメモ
この泥臭い方法でピクセルとポイントの比を求める。
しかし「できるだけ大きくして」確認する
301pixels 37.00 Points
が求められるので
37/301=0.12292
同様に縦幅も
225/300=0.75
が求められる。
どうも縦幅の0.75は安定しているようだ。
VBAのコード作成
参考にするコード
ピクセル単位でセルの高さと幅を指定する
を改造する
Publisherの活用
ここでcentimeterstopoints、MillimetersToPoints(1)
を使う。
まずLの長さをセンチで出す。
Int式は四捨五入で端数を切っている。
Constで先ほど求めた換算値を定義する。
なおセルのフォントは換算値を定義したフォント、フォントサイズにすること
参照設定している場合には
Dim pbApp As New Publisher.Application
を使うが、今回はレイトバインディングにした。
補正値の導入
何回か印刷し、縦横のサイズが1mm程度の誤差がないか確認する。
pbApp.MillimetersToPoints(1)
縦幅は0.75単位で細かくないためどうしても補正が必要になる、上記の項目が下記のコードのRowHeightに含まれている。ただし上記の理由で完全に方眼にはならない。
10mm 方眼
Sub MakeExcel10mmSecpaper()
Dim wb As Workbook: Set wb = ActiveWorkbook
Dim ws As Worksheet: Set ws = ActiveSheet
Dim r As Range: Set r = ws.Range(ActiveCell.Address)
'Dim pbApp As New Publisher.Application 'Early Binding ( Refernse Setting)
Dim pbApp As Object: Set pbApp = CreateObject("Publisher.Application")
'MS ゴシック 日本語 11
'http://yumem.cocolog-nifty.com/excelvba/2010/01/post-db58.html
'
Const conRowPixcel = 0.1229 'Point
Const conColPixcel = 0.75
Dim L As Double
L = Int(pbApp.PointsToPixels(pbApp.CentimetersToPoints(1)) + 0.5)
For Each r In Selection
r.ColumnWidth = L * conRowPixcel
r.RowHeight = r.ColumnWidth * (conColPixcel * 100) / (conRowPixcel * 100) + pbApp.MillimetersToPoints(1)
Next
Set pbApp = Nothing 'LateBinding Only
End Sub
10mmの結果
高さ 41ピクセル
幅 42ピクセル
補正値をかませているのもあるが、概ね10mmになり1ピクセルしか差がない。
5mm
Sub MakeExcel05mmSecspaper()
Dim wb As Workbook: Set wb = ActiveWorkbook
Dim ws As Worksheet: Set ws = ActiveSheet
Dim r As Range: Set r = ws.Range(ActiveCell.Address)
Dim pbApp As New Publisher.Application 'Early Binding ( Refernse Setting)
'Dim pbApp As Object: Set pbApp = CreateObject("Publisher.Application")
'MS ゴシック 日本語 11
'http://yumem.cocolog-nifty.com/excelvba/2010/01/post-db58.html
'http://yumem.cocolog-nifty.com/excelvba/2010/02/post-7fcc.html
Const conRowPixcel = 0.1229 'Point
Const conColPixcel = 0.75
Dim L As Double
L = Int(pbApp.PointsToPixels(pbApp.CentimetersToPoints(1.5)) + 0.5)
For Each r In Selection
r.ColumnWidth = L * conRowPixcel '- pbApp.MillimetersToPoints(0.2)
r.RowHeight = r.ColumnWidth * (conColPixcel * 100) / (conRowPixcel * 100) + pbApp.MillimetersToPoints(1)
Next
Set pbApp = Nothing 'LateBinding
End Sub
5mm結果
高さ 24ピクセル
幅 24ピクセル
ただし微妙に0.5cmにはなっていないが縦横同じというところだけがいいところだ。
15mm
幅はほぼ正確に出るが、縦が短い。0.1mm補正値を増加させる
Sub MakeExcel05mmSecspaper()
Dim wb As Workbook: Set wb = ActiveWorkbook
Dim ws As Worksheet: Set ws = ActiveSheet
Dim r As Range: Set r = ws.Range(ActiveCell.Address)
Dim pbApp As New Publisher.Application 'Early Binding ( Refernse Setting)
'Dim pbApp As Object: Set pbApp = CreateObject("Publisher.Application")
'MS ゴシック 日本語 11
'http://yumem.cocolog-nifty.com/excelvba/2010/01/post-db58.html
'http://yumem.cocolog-nifty.com/excelvba/2010/02/post-7fcc.html
Const conRowPixcel = 0.1229 'Point
Const conColPixcel = 0.75
Dim L As Double
L = Int(pbApp.PointsToPixels(pbApp.CentimetersToPoints(1.5)) + 0.5)
For Each r In Selection
r.ColumnWidth = L * conRowPixcel '- pbApp.MillimetersToPoints(0.2)
r.RowHeight = r.ColumnWidth * (conColPixcel * 100) / (conRowPixcel * 100) + pbApp.MillimetersToPoints(1.1)
Next
Set pbApp = Nothing 'LateBinding
End Sub
15mm結果
高61Pixcels(45.75pts)
幅61Pixels(7pts)
考察
幅はおおむね正確に指定したmm単位の幅を反映する。
おそらく0.1229という換算値が高さの換算値の0.75より小さいため、mm単位の幅を反映しやすいのだろう。
他方、高さは0.75ピクセル単位でしか動かないため、多少の誤差が出やすい。このため印刷して定規で誤差をはかり、0.1mm単位で補正値を足すとよい。(目分量だが)
またExcelが得意なのは5㎜方眼といえる。
ただし
Excel方眼を考えた奴はまじで常軌を逸したキチガイとしか言えない。Excelをまるで理解していないし、そもそもアナログの印刷すら理解していない。無知、無教養、文化をわかっていないうすらトンカチのメガトン級の無能バカである。人間としての基礎的な素養がないということを意味しており反知性主義の原始人で、方眼紙を買わないケチである。