|
わぁ、出力範囲は [B2:D15] だけでしたか?
>Sub 範囲をCSV出力2()
> '対象シートをアクティブにして実行
> Dim myPath As String
> Dim myCSV As String
> Dim io As Integer
> Const CLSID_DataObject = "1C3B4210-F441-11CE-B9EA-00AA006B1A69"
>
> myPath = "C:\Documents and Settings\fumi_T\デスクトップ"
> If Right$(myPath, 1) <> "\" Then myPath = myPath & "\"
>
> io = FreeFile()
> With ActiveSheet
> myCSV = myPath & .[A1].Value & .[B1].Value & ".Csv"
> Open myCSV For Output As io
.[B2:D15].Copy '---> 2.範囲B2:D15 をクリップボードに送る
> End With
> With GetObject("new:" & CLSID_DataObject)
> .GetFromClipboard 'Clipboard文字列を DataObjectで取得
> Print #io, Replace(.GetText(1), vbTab, ","); 'TABをカンマに置換出力
> End With
> Close io
> Application.CutCopyMode = False
> MsgBox "出力しました", , myCSV
>End Sub
|
|