Function Transformar(ByVal DocPath As String, ByVal Tipo As String, Optional ByRef DestDir As String) As String
Dim TmpPath As String
Dim FileName As String
Dim File As String
Dim archivo As String
TmpPath = TempDir() & "Doc2HTML\"
On Error Resume Next
MkDir TmpPath
On Error GoTo 0
If DestDir = "" Then DestDir = TmpPath
If Right$(DestDir, 1) <> "\" Then DestDir = DestDir & "\"
SplitPath DocPath, Title:=FileName
File = Dir$(TmpPath & "*")
Do While Len(File)
Kill TmpPath & File
File = Dir$
Loop
archivo = DestDir & FileName & ".htm"
Select Case UCase(Tipo)
Case "DOC": TransformarDocumentos = Word(DocPath, archivo)
Case "XLS": TransformarDocumentos = Excel(DocPath, archivo)
Case "PPT": TransformarDocumentos = PowerPoint(DocPath, archivo)
Case "PPS": TransformarDocumentos = PowerPoint(DocPath, archivo)
Case "TXT": TransformarDocumentos = Word(DocPath, archivo)
Case Else
TransformarDocumentos = "2"
End Select
If DestDir <> TmpPath Then
On Error Resume Next
MkDir DestDir
On Error GoTo 0
File = Dir$(TmpPath & "*")
Do While Len(File)
FileCopy TmpPath & File, DestDir & File
Kill TmpPath & File
File = Dir$
Loop
On Error Resume Next
RmDir TmpPath
On Error GoTo 0
End If
If TransformarDocumentos = "1" Then
Transformar = "La Transformacion del Archivo fue Exitosa"
Else
Transformar = "Transformacion para este Archivo no disponible"
End If
End Function
Private Function TempDir() As String
Static Path As String
If Path = "" Then
Path = Environ$("TEMP")
If Path = "" Then
Path = Environ$("TMP")
If Path = "" Then Path = "C:\Temp"
End If
If Right$(Path, 1) <> "\" Then Path = Path & "\"
On Error Resume Next
MkDir Path
On Error GoTo 0
End If
TempDir = Path
End Function
sigue....