1.插入按钮,在开发工具项-插入表单工具-Button
2.导入代码
Sub Inport_Renkei_CSV_Click()
Dim fTextDir As String, rowIndex As Integer, i As Integer
myFile = Application.GetOpenFilename("连携CSVファイル(*.csv),*.csv")
If VarType(myFile) = vbBoolean Then
Exit Sub
End If
rowIndex = 1
Open myFile For Input As #1
Do While Not EOF(1)
Line Input #1, currLine
If rowIndex > 1 Then
rowDataArr = Split(currLine, Chr(9))
For i = 0 To UBound(rowDataArr)
Cells(rowIndex + 1, i + 1).FormulaR1C1 = rowDataArr(i)
Next i
End If
rowIndex = rowIndex + 1
Loop
Close #1
MsgBox "success"
End Sub
dim shp1 as shape
set shp1 =sheet1.addformcontrol(xlbuttoncontrol,10,50,100,20)
shp1.textframe.characters.text="按钮"
shp1.onaction=" 宏1"
with active sheet.querrytables.add(connection:="text",path&文件名,range("a1"))
.Textfileplatform=936
. textfilecommadelimiter=true
.Refresh
end with