仅将 xlsm 文件添加到组合框 VBA
Add only xlsm files to combobox VBA
这是我第一次在这个论坛上提问,我有这段代码可以将一些文件添加到用户表单中的组合框,但问题是我只需要添加 .xlsm 文件,但我来的代码up with 添加了我的每个文件,我该怎么做?
这是我的代码:
Dim Pathh As String
Dim fila As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Path = "Z:\Primera Inspección\" & Alertas_Mes.Controls("Label" & i).Caption
Set carpeta = fso.getfolder(Path)
If carpeta <> Pathh Then GoTo Sig
Set ficheros = carpeta.Files
For Each ficheros In ficheros
b = ficheros.Name
Alertas_Mes.Controls("Combobox" & i).AddItem b
Next ficheros
应该像放入 If 语句一样简单
Dim Pathh As String
Dim fila As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Path = "Z:\Primera Inspección\" & Alertas_Mes.Controls("Label" & i).Caption
Set carpeta = fso.getfolder(Path)
If carpeta <> Pathh Then GoTo Sig
Set ficheros = carpeta.Files
For Each ficheros In ficheros
b = ficheros.Name
if(b like "*.xlsm") then
Alertas_Mes.Controls("Combobox" & i).AddItem b
end if
Next ficheros
检查文件扩展名:
For Each ficheros In ficheros
b = ficheros.Name
If Right(b, 5) = ".xlsm" Then Alertas_Mes.Controls("Combobox" & i).AddItem b
Next ficheros
这是我第一次在这个论坛上提问,我有这段代码可以将一些文件添加到用户表单中的组合框,但问题是我只需要添加 .xlsm 文件,但我来的代码up with 添加了我的每个文件,我该怎么做?
这是我的代码:
Dim Pathh As String
Dim fila As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Path = "Z:\Primera Inspección\" & Alertas_Mes.Controls("Label" & i).Caption
Set carpeta = fso.getfolder(Path)
If carpeta <> Pathh Then GoTo Sig
Set ficheros = carpeta.Files
For Each ficheros In ficheros
b = ficheros.Name
Alertas_Mes.Controls("Combobox" & i).AddItem b
Next ficheros
应该像放入 If 语句一样简单
Dim Pathh As String
Dim fila As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Path = "Z:\Primera Inspección\" & Alertas_Mes.Controls("Label" & i).Caption
Set carpeta = fso.getfolder(Path)
If carpeta <> Pathh Then GoTo Sig
Set ficheros = carpeta.Files
For Each ficheros In ficheros
b = ficheros.Name
if(b like "*.xlsm") then
Alertas_Mes.Controls("Combobox" & i).AddItem b
end if
Next ficheros
检查文件扩展名:
For Each ficheros In ficheros
b = ficheros.Name
If Right(b, 5) = ".xlsm" Then Alertas_Mes.Controls("Combobox" & i).AddItem b
Next ficheros