- VB,VBA
-
2016-11-28 - 更新:2021-01-13
AccessからExcelを操作し、罫線等を設定する場合、私自身もいつも定数の値が何だったかいちいち調べているので、備忘録も兼ねて書いておきます。
まずは全体の流れ
Dim ws
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim FileName As String
Set ws = CreateObject("WScript.Shell")
FileName = ws.SpecialFolders("Desktop") & "\雛形.xlsx"
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(FileName)
Set xlSheet = xlBook.WorkSheets(1)
With xlSheet
'このブロック内に書いていきます
End With
'保存
xlBook.Save
xlBook.Close
xlApp.Application.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
罫線を引く
.Range("A1:I1").Borders.LineStyle = 1
.Range("A1:I1").Borders(8).LineStyle = -4118
.Range("A1:I1").Borders(11).LineStyle = -4115
.Range("A1:I1").Borders(11).Weight = 1







