Consulting

Results 1 to 5 of 5

Thread: How to show save as dailog box

  1. #1
    VBAX Regular
    Joined
    Jan 2012
    Posts
    23
    Location

    How to show save as dailog box

    How to do that , when I DblClick the image, the SAVE AS dailog box pop up and save file format is jpg.
    Attached Files Attached Files

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [VBA]Sub Test_SaveAs()
    SaveAs ThisWorkbook.path & "\Test.xls"
    End Sub

    Sub SaveAs(initialFilename As String)
    With Application.FileDialog(msoFileDialogSaveAs)
    .AllowMultiSelect = False
    .ButtonName = "&Save As"
    .initialFilename = initialFilename
    .Title = "File Save As"
    .Execute
    .Show
    End With
    End Sub

    Sub Test_SaveAs2()
    SaveAs2 ThisWorkbook.path & "\Test.xls"
    End Sub

    Sub SaveAs2(initialFilename As String)
    Dim filespec As String
    filespec = Application.GetSaveAsFilename(initialFilename:=initialFilename, FileFilter:="Microsoft Excel files (*.xls), *.xls", Title:="Save As2")
    If filespec <> "" And filespec <> False Then ActiveWorkbook.SaveAs filespec
    End Sub[/VBA]

  3. #3
    VBAX Regular
    Joined
    Jan 2012
    Posts
    23
    Location
    Thankyou for you help.

    but my problem is when I double click the image (inside userform) the save as dailog box pop up and I can save the image to other location in jpeg file.

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    If I am understanding correctly, we could use SavePicture to save the image control's picture as a bitmap. Borrowing from Kenneth, maybe something like:
    [vba]Option Explicit

    Private Sub Image1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    If SaveAs2("MyTest.bmp") Then Unload Me
    End Sub

    Private Function SaveAs2(InitialFilename As String) As Boolean
    Dim filespec As String

    filespec = Application.GetSaveAsFilename(InitialFilename:=InitialFilename, FileFilter:="BitMap (*.bmp), *.bmp", Title:="Save As BitMap")
    If filespec <> "" And filespec <> "False" Then
    SavePicture Me.Image1.Picture, filespec
    SaveAs2 = True
    End If
    End Function
    [/vba]
    Does that help?

    Mark

  5. #5
    VBAX Regular
    Joined
    Jan 2012
    Posts
    23
    Location
    Yes, thankyou very much for your help.

    An other problem, original picture size is 140KB but after run VBA save as picture to MyTest.bmp / MyTest.jpg....
    The picture is too large (file size more than 60MB)

    WHY?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •