我已成功找到了如何使用ANT SDK ANT link将FIT文件(由Garmin Forerunner 620手表制作)转换为CSV格式。代码在VBA(循环)中,包含执行Java JAR文件的shell命令。这种方法有两个主要的烦恼:
VBA代码:
Sub RunJarJarBinks()
Dim FITfileFOLDER As Object
Dim FiLe As Object
Dim FSO As Object
Dim FLpath As String
Dim wb As Workbook
Dim FiLeCollect As Object
Dim repNAME As String
Set wb = ThisWorkbook
FLpath = wb.Path
Set FSO = CreateObject("scripting.filesystemobject")
Set FITfileFOLDER = FSO.GetFolder(FLpath)
Set FiLeCollect = FITfileFOLDER.Files
ChDir ThisWorkbook.Path
For Each FiLe In FiLeCollect
If Right(FiLe.Name, 4) = ".FIT" Then
repNAME = Replace(FiLe.Name, ".FIT", "") & "_session"
SHELL "java.exe -jar FitCSVTool.jar -b C:\users\devin\downloads\FIT_files\" & FiLe.Name & " C:\users\devin\downloads\FIT_files\" & repNAME & " --data"
Application.Wait (Now + 1 / 24 / 60 / 60 * 1)
End If
Next
ChDir ThisWorkbook.Path
For Each FiLe In FiLeCollect
If Right(FiLe.Name, 4) = ".FIT" Then
repNAME = Replace(FiLe.Name, ".FIT", "") & "_lap"
SHELL "java.exe -jar FitCSVTool.jar -b C:\users\devin\downloads\FIT_files\" & FiLe.Name & " C:\users\devin\downloads\FIT_files\" & repNAME & " --defn none --data lap"
Application.Wait (Now + 1 / 24 / 60 / 60 * 1)
End If
Next
End Sub
我认为最好的答案是利用SDK中包含的BAT文件。我可以将所有FIT文件拖放到BAT文件中,并且它们可以快速转换而无需额外的文件。所以,我的问题是 - 如果BAT文件是正确的解决方案,那么如何在VBA中初始化它并将文件名传递给BAT文件(作为数组?)?否则,我想我需要将循环移动到JAR文件中?
BAT文件代码:
@echo off
setlocal EnableDelayedExpansion
set APP_DIR=%~dp0
set APP_NAME=FitCSVTool.jar
set APP_PATH="%APP_DIR%%APP_NAME%"
set a=%*
FOR %%b IN (!a!) DO (
set c=%%b
set c=!c:.fit=!
call java -jar %APP_PATH% -b %%b !c!
)
pause