excel录制宏的基础上,加了几句(导入文本数据生成折线)
Sub 宏1() ' ' 宏1 宏 ' Name = "test3" Worksheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Name ' With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Users\Administrator\Desktop\" & Name & ".txt", Destination:=Range("$A$2")) .Name = "test" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 936 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Application.Left = 352.75 Application.Top = 66.25 Range("B1").Select ActiveCell.FormulaR1C1 = "kang_" & Name Columns("B:B").Select ActiveSheet.Shapes.AddChart.Select ActiveChart.ChartType = xlLine ActiveChart.SetSourceData Source:=Range(Name & "!$B:$B") End Sub