Could someone share the code for saving an image file such as jpg or bmp to another file named by the (Save As) Common Dialog box. No problem generating the Common Dialog but having problems with SavePicture.
Thanks RSH
This is what my code looks like.
Note that savepicture always saves the image in a bitmap file (.bmp). VB does not support other formats by default, you'll need additional module/dll/code for that.
Sunaj
---------------------------------------------------------------
tmp = SaveFileAs("map1.bmp", , "d:\vb\roscop\map\plots\"
If tmp <> "" Then
MousePointer = vbHourglass
SavePicture Image, tmp
MousePointer = vbDefault
End If
Private Function SaveFileAs(DefaultFile As String, Optional DefaultTitle As String = "Save plot", Optional DefaultPath As String = "C:\tmp\" As String
On Error GoTo ErrHndl:
ComDlg.DialogTitle = DefaultTitle
ComDlg.CancelError = True
ComDlg.Flags = cdlOFNOverwritePrompt
ComDlg.InitDir = DefaultPath
ComDlg.FileName = DefaultFile
ComDlg.Action = 2
SaveFileAs = ComDlg.FileName
Exit Function
ErrHndl: ' return a null string if the user cancels
If Err.Number = 32755 Then
SaveFileAs = ""
Else
MsgBox (Err.Description)
End If
End Function
---------------------------------------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.