7
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VBAでExcelに数式(TeXみたいなやつのほう)を挿入

Last updated at Posted at 2018-01-20

Officeの数式をVBAで書くにはどうすればいいかというメモ。

検索すると、Excelのセルで計算するほうの数式が引っかかってしまい、欲しい答えになかなかたどり着かなかった。

参考

コード

Sub InsertEquation(left, top, str)
	ActiveSheet.Shapes.AddLabel(msoTextOrientationHorizontal, left, top, 0, 0).Select
	Application.CommandBars.ExecuteMso "InsertBuildingBlocksEquationsGallery"
	Selection.Text = str
	Selection.Font.Size = 24
	Selection.ShapeRange.TextFrame2.WordWrap = msoFalse
	Application.CommandBars.ExecuteMso "EquationProfessional"
End Sub

Sub Sample()
	InsertEquation 30, 40, "F(t)=\sum_(x=0)^(n-1) \of \begin f(x) e^(-\ii  2\pi tx/N) \end"
End Sub

vba_insert_equation.png

7
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?