タイトル | : Re: excelのセルの統合の仕方 |
記事No | : 447 |
投稿日 | : 2003/09/18(Thu) 23:13 |
投稿者 | : 魔界の仮面弁士 |
> VBからエクセルのセルを指定して統合したいのですが > 可能でしょうか?
RangeオブジェクトのMergeメソッドを呼び出してやればOKです。 たとえば、こんな感じですかね。
Option Explicit On Option Strict On Imports Microsoft.VisualBasic Imports Microsoft.VisualBasic.Interaction Imports System.Runtime.InteropServices.Marshal Module Module1 Function Main(ByVal CmdArgs() As String) As Integer Dim oApp As Object = CreateObject("Excel.Application") CallByName(oApp, "Visible", CallType.Let, True) Dim oWBs As Object = CallByName(oApp, "Workbooks", CallType.Get) Dim oWB As Object = CallByName(oWBs, "Add", CallType.Method) Dim oWSs As Object = CallByName(oWB, "Worksheets", CallType.Get) Dim oWS As Object = CallByName(oWSs, "Item", CallType.Get, 1) Dim oRng As Object = CallByName(oWS, "Range", CallType.Get, "B2:C3")
CallByName(oRng, "Merge", CallType.Method) CallByName(oRng, "Value", CallType.Let, "結合結果")
ReleaseComObject(oRng) : oRng = Nothing ReleaseComObject(oWS) : oWS = Nothing ReleaseComObject(oWSs) : oWSs = Nothing ReleaseComObject(oWB) : oWB = Nothing ReleaseComObject(oWBs) : oWBs = Nothing ReleaseComObject(oApp) : oApp = Nothing End Function End Module
|