Private Sub ÖppnaBild_Click() Har löst det: Med en Sven Pont..areProblem att spara bild .jpg
On Error GoTo Felhanterare:
Dim sFile As String
With CommonDialog2
.DialogTitle = "Open"
.CancelError = True
.FilterIndex = 2
.Filter = "Alla Filer (*.jpg)|*.jpg"
.InitDir = ""
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
sFile = .FileName
End With
Image2.Picture = LoadPicture(CommonDialog2.FileName)
Felhanterare:
End Sub
//
Att öppna bilden till en ImageBox Inga problem....
Men sen spara om den i nytt namn via nedanstående kod...
//
Private Sub SparaBild_Click()
Dim sFile As String
With CommonDialog3
With CommonDialog3
.DialogTitle = "Save"
.CancelError = False
.FilterIndex = 2
.Filter = "Alla filer (*.jpg)|*.jpg"
.ShowSave
If Len(.FileName) = 0 Then
Exit Sub
End If
sFile = .FileName
End With
Image2.Picture.SaveFile < "Här ligger felet. Hur ska jag koda raden??"
End With
End Sub
//Mvh KennethSv: Problem att spara bild .jpg
Genom energiskt sökande hittade jag en exempelkod
Hursomhelst Tackar jag
.....
Private Sub Sparabild_Click()
Dim sFile As String
With CommonDialog3
With CommonDialog3
.DialogTitle = "Save"
.CancelError = False
.FilterIndex = 2
.Filter = "Alla filer (*.jpg)|*.jpg"
.ShowSave
If Len(.FileName) = 0 Then
Exit Sub
End If
sFile = .FileName
End With
Dim SearchPath As String
SearchPath = App.Path
If Right$(SearchPath, 1) <> "\" Then _
SearchPath = SearchPath & "\"
SavePicture Image1.Picture, SearchPath & "Test.bmp"
End With
End Sub