Am 14.06.2017 um 00:38 schrieb Ulrich Möller:
Public Sub MergeFiles(ByVal InFile As String, ByVal OutFile As String)
Const COPYCMD As String = "for %f in ({0}) do type ""%f"" {1}"
Dim strCopyCommand As String
Dim dblRetVal As Double
strCopyCommand = Replace(COPYCMD, "{0}", InFile)
strCopyCommand = Replace(strCopyCommand, "{1}", OutFile)
SyncShell "cmd.exe /c " & strCopyCommand, vbNormalFocus
End Sub
Sorry for the mixed data types, here the corrected version:
Public Sub MergeFiles(ByVal InFile As String, ByVal OutFile As String)
Const COPYCMD As String = "for %f in ({0}) do type ""%f"" {1}"
Dim strCopyCommand As String
Dim lngRetVal As Long
strCopyCommand = Replace(COPYCMD, "{0}", InFile)
strCopyCommand = Replace(strCopyCommand, "{1}", OutFile)
lngRetVal = SyncShell("cmd.exe /c " & strCopyCommand, vbNormalFocus)
End Sub
Public Function SyncShell(ByVal Cmd As String, ByVal WindowStyle As
VbAppWinStyle) As Long
SyncShell = VBA.CreateObject("WScript.Shell").Run(Cmd, WindowStyle, True)
End Function
Ulrich
Hey Ulrich,
Nice to see you 'spreading your wings'!<g
FWIW:
My experience with users for this type of utility is (typically) where a share
folder is used as a repository for collecting data from various sources over a
given period. Once per period the data gets consolidated into a single file for
processing further by some means, and the source files get deleted so the
folder only contains un-processed data files.
That said, your example could be modified to drill drown a selected folder (and
optionally, subfolders) so the user doesn't have to specify filenames. Your
sample addresses EXACTLY what the OP states is wanted; -I'm guessing that's not
the 'actual' scenario...<g
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion