Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem to run

Hi,
When running the macro below

Sub AA_Validate_Path_vgm()
    Dim Obj0 As Object, Source0 As Object, File0 As Variant, File1 As String, File2 As String, Pos0 As Integer, Pos1 As Integer, Pos2 As Integer, Pos3 As Integer, iFile As Integer, TextLine As String, Str0 As String, Command0 As String, FSO As Object, Path0 As String, Message0 As String
        
    Set FSO = CreateObject("scripting.filesystemobject")
    File0 = Dir("C:\cmp3g\CODECO_ERROR_0\*.*", 7)
    Do While (File0 <> "" And UCase(File0) <> "ERROR.TXT")
        'Debug.Print File0
        File1 = "C:\cmp3g\CODECO_ERROR_0\" & File0
        iFile = FreeFile
        Open File1 For Input As #iFile
        Do Until EOF(1)
            Line Input #1, TextLine
            
            If Trim(TextLine) <> "" Then
            Pos0 = InStr(TextLine, "UNOA")
            If (Pos0 > 0) Then
                Pos1 = InStr(Pos0 + 1, TextLine, "+")
                Pos2 = InStr(Pos1 + 1, TextLine, "+")
                Pos3 = InStr(Pos1 + 1, TextLine, ":")
                
                If Pos3 < Pos2 Then
                    Pos2 = Pos3
                End If
                
                Message0 = ""
                Str0 = Mid(TextLine, Pos1 + 1, Pos2 - 1 - Pos1)
                'Debug.Print Str0
                If Len(Str0) > 0 Then
                    'Path0 = "C:\cmp3g\CODECO_ERROR_0\" & Str0 & "\"
                    
                    'If FSO.FolderExists(Path0) = False Then
                        'Command0 = "cmd /c mkdir """ & Path0 & """ "
                        'Shell (Command0)
                        'MkDir (Path0)
                        
                        'DoEvents
                        'Application.Wait Now + TimeValue("00:00:07")
                        
                    'End If
                
                    If UCase(File0) <> "ERROR.TXT" Then
                        'Command0 = "cmd /c copy /y ""C:\cmp3g\CODECO_ERROR_0\" & File0 & """ ""C:\cmp3g\CODECO_ERROR_0\" & Str0 & """ "
                        'Shell (Command0)
                    
                        'FileCopy "C:\cmp3g\CODECO_ERROR_0\" & File0  "C:\cmp3g\CODECO_ERROR_0\" & Str0
                        'Debug.Print File0 & " x1 " & Str0
                        'Debug.Print File2 & " x2 " & Str0
                        'DoEvents
                        'Application.Wait Now + TimeValue("00:00:07")
                        
                        File2 = File0
                        'Validate_File Str0, File0, Message0
                        Shell ("C:\cmp3g\CODECO_ERROR_0\Validate_File1 """ & Str0 & """ """ & File2 & """")
                    End If
                    
                    Exit Do
                End If
                
            End If
            End If
        Loop
        Close #iFile
        
        File0 = Dir
    Loop
End Sub

Open in new window

within LibreOffice 5.1.2, I get nothing happened, while in Excel 2010, everything is fine.

why?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

For one thing - does that file path exist on your machine?
Avatar of Peter Chan

ASKER

Yes, all are existing inside the machine.
Avatar of Norie
Norie

Are you sure LibreOffice can run that code?

Macros in MS Office and LibreOffice.
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I want to know how we can ensure the workable codes in MS office can also "move" within LibreOffice.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It means LibreOffice does not "fully" support Excel functionalities.
Or can I say, since LibreOffice does NOT have VBA/VB script to CALC at all?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial