Hi,
I have this worksheet that imports a file- bom.rpt. Now i want to replace this file with an excel or word document.
I made changes to the code accordingly but when it imports it works in the begining but later the data becomes garbelled.
I have little practice with VBA and the using series book for Excel hasnt helped me solve this problem.If soemone has a solution , I would reallly apprciate.
here is the part where the worksheet accesses the external data file.
Sub Update_BM_Data()
'
' Define variables "fname" and "fpath"
'
' "fpath" is assigned the current path for the MP workbook.
' "fname" is the complete file name, path and type of the target for
' the data query used to import the Business Works data.
' A complete file named "Bom.rpt" in the same directory as the
' MP workbook.
'
Dim fname
Dim fpath
fpath = ActiveWorkbook.Path
fname = "TEXT;" & fpath & "\Bom.rpt"
'
' Select and clear the appropriate sheet in the MP workbook
'
Sheets("BOM data".Select
Clearsheet
'
' Import the bw data
'
With ActiveSheet.QueryTables.Add(Connection:=fname, Destination:=Range("A1")
.Name = "Bom"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(15, 32, 10, 11)
.Refresh BackgroundQuery:=False
End With
Look in forward to a response,
Thanks,
Gary
I have this worksheet that imports a file- bom.rpt. Now i want to replace this file with an excel or word document.
I made changes to the code accordingly but when it imports it works in the begining but later the data becomes garbelled.
I have little practice with VBA and the using series book for Excel hasnt helped me solve this problem.If soemone has a solution , I would reallly apprciate.
here is the part where the worksheet accesses the external data file.
Sub Update_BM_Data()
'
' Define variables "fname" and "fpath"
'
' "fpath" is assigned the current path for the MP workbook.
' "fname" is the complete file name, path and type of the target for
' the data query used to import the Business Works data.
' A complete file named "Bom.rpt" in the same directory as the
' MP workbook.
'
Dim fname
Dim fpath
fpath = ActiveWorkbook.Path
fname = "TEXT;" & fpath & "\Bom.rpt"
'
' Select and clear the appropriate sheet in the MP workbook
'
Sheets("BOM data".Select
Clearsheet
'
' Import the bw data
'
With ActiveSheet.QueryTables.Add(Connection:=fname, Destination:=Range("A1")
.Name = "Bom"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(15, 32, 10, 11)
.Refresh BackgroundQuery:=False
End With
Look in forward to a response,
Thanks,
Gary