Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(Save As) Common Dialog Box

Status
Not open for further replies.

RSH

Technical User
Jun 15, 2000
55
0
0
US
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
 
Hi,

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 <> &quot;&quot; Then
MousePointer = vbHourglass
SavePicture Image, tmp
MousePointer = vbDefault
End If


Private Function SaveFileAs(DefaultFile As String, Optional DefaultTitle As String = &quot;Save plot&quot;, Optional DefaultPath As String = &quot;C:\tmp\&quot;) 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 = &quot;&quot;
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'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top