exceldemon
New Member
- Joined
- Jun 30, 2010
- Messages
- 38
I have a VBA script from a 3D modeling program I use that opens a Excel Workbook and adds text to it. Everything works just fine but when I close the workbook, Excel still shows up in the Task Manager. If I run my macro again, it doesnt work. If I end the task in the Task Manager, it works again.
Here is the code I use to open the existing Worksheet that hads a header, then imports text.
Here is the code I use to open the existing Worksheet that hads a header, then imports text.
Code:
Private Function convertexcel()
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Set xlApp = New Excel.Application
xlApp.Visible = False
xlApp.DisplayAlerts = False
ChDir "V:\MyFolder"
Workbooks.Open FileName:= _
"V:\MyFolder\ENGR STANDARD.xlsx" _
, UpdateLinks:=0, Notify:=False
Range("A12:M15").Select
Selection.Delete Shift:=xlUp
Range("D19").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\tempbom.txt", _
Destination:=Range("$A$12"))
.Name = "tempbom"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlFormatFromLeftOrAbove
.SavePassword = False
.SaveData = True
'.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Rows("12:12").Select
Selection.Delete Shift:=xlUp
' Columns("C:C").Select
' With Selection
' .HorizontalAlignment = xlLeft
' End With
Range("D1").Select
xlApp.Visible = True
End Function