jchewsmith
Technical User
I am trying to find a way to export from a crystal report (or several reports) into an excel file with each report or subreport showing on a separate sheet.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub IMPORT_fromFolder()
'SkilVought 2018 Jun 26
'run in Excel
Dim oFSO As Object, oFile As Object, sPath As String, sDB As String
Set oFSO = CreateObject("Scripting.FileSystemObject")
sPath = "C:\Users\Skip\Documents\TT\Test_CSV"
For Each oFile In oFSO.GetFolder(sPath).Files
With oFile
'file name
sDB = oFile.Name
'add a sheet for this file
ThisWorkbook.Worksheets.Add
'import
With ActiveSheet
.Name = Split(sDB, ".")(0)
With .QueryTables.Add( _
Connection:="TEXT;" & sPath & "\" & sDB, _
Destination:=Range("$A$1"))
.Name = Split(sDB, ".")(0)
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With
End With
Next
End Sub