试下面的代码 Private Sub Command1_Click() Dim mFilePath$ Dim i%CommonDialog1.ShowSave mFilePath$ = Left$(CommonDialog1.FileName, InStrRev(CommonDialog1.FileName, "\") - 1)For i = Image1.LBound To Image1.UBound SavePicture Image1(i).Picture, mFilePath$ & "\img" & i & ".bmp" NextEnd Sub
楼主在思路上可能有点偏差,也或许我没理解楼主的意思CommonDialog的ShowSave或ShowOpen 是针对文件而非文件夹,你要保存100张图片不可能用一个文件来存,而是应该选一个文件夹来存你这100多张的图片. Dim SelFolder$, i& Private Sub Command1_Click() On Error GoTo errhandler '有错误或选择取消返回32755的错误代号,执行错误处理副程序 Set spShell = CreateObject("Shell.Application") '创建对像 Set spFolder = spShell.BrowseForFolder(0, "选择目录:", 0, ssfDRIVES) '定义spFolder=定义对像展开目录 Set spFolderItem = spFolder.Self '定义spFolderItem SelFolder = spFolderItem.Path 'SelFolder=选中的spFolderItem文件夹路径 If Right(SelFolder, 1) <> "\" Then SelFolder = SelFolder & "\" '选择的路径最后面加上\ For i = 1 To 100 '看你自己定义的IMAGE数组范围,我给你保持3位数所以用FORMAT 000 SavePicture Image1(i).Picture, SelFolder & Format(CStr(i), "000") & ".bmp" Next i MsgBox "保存完成" errhandler: '错误处理副程序 If Err > 0 Then MsgBox "您选择了取消或程序有错误": Exit Sub End Sub
Private Sub Command1_Click()
Dim mFilePath$
Dim i%CommonDialog1.ShowSave
mFilePath$ = Left$(CommonDialog1.FileName, InStrRev(CommonDialog1.FileName, "\") - 1)For i = Image1.LBound To Image1.UBound
SavePicture Image1(i).Picture, mFilePath$ & "\img" & i & ".bmp"
NextEnd Sub
Dim SelFolder$, i&
Private Sub Command1_Click()
On Error GoTo errhandler '有错误或选择取消返回32755的错误代号,执行错误处理副程序
Set spShell = CreateObject("Shell.Application") '创建对像
Set spFolder = spShell.BrowseForFolder(0, "选择目录:", 0, ssfDRIVES) '定义spFolder=定义对像展开目录
Set spFolderItem = spFolder.Self '定义spFolderItem
SelFolder = spFolderItem.Path 'SelFolder=选中的spFolderItem文件夹路径
If Right(SelFolder, 1) <> "\" Then SelFolder = SelFolder & "\" '选择的路径最后面加上\
For i = 1 To 100 '看你自己定义的IMAGE数组范围,我给你保持3位数所以用FORMAT 000
SavePicture Image1(i).Picture, SelFolder & Format(CStr(i), "000") & ".bmp"
Next i
MsgBox "保存完成"
errhandler: '错误处理副程序
If Err > 0 Then MsgBox "您选择了取消或程序有错误": Exit Sub
End Sub
http://download.csdn.net/source/358211