vb編程修改文件后綴名?
將生成的exe放入文件夾
Private TxtName() As String '定義一個數組裝入txt名稱
Dim sPath As String
Sub GetTxtName(ByVal sPath As String, ByVal Filter As String) '這是獲取指定文件夾下指定后綴名的文件名稱的過程,裝入數組txtname()中,spath就是這里寫放txt的文件夾路徑
Dim sDir As String
Dim sFilter() As String
Dim lngFilterIndex As Long
Dim lngIndex As Long
sFilter = Split(Filter, ",")
If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
For lngFilterIndex = LBound(sFilter) To UBound(sFilter)
sDir = Dir(sPath & sFilter(lngFilterIndex))
Do While Len(sDir) > 0
lngfiles = lngfiles + 1
ReDim Preserve TxtName(1 To lngfiles)
TxtName(lngfiles) = sDir
sDir = Dir
Loop
Next
End Sub
Private Sub Command1_Click()
Dim i%
sPath = App.Path & "\"
Call GetTxtName(sPath, "*.html")
For i = 1 To UBound(TxtName)
Name sPath & TxtName(i) As sPath & Left(TxtName(i), InStr(TxtName(i), ".") - 1) & ".pdf"
Next
MsgBox "Done!"
End Sub