Resim olarak kaydetme

bthn35

Altın Üye
Katılım
12 Kasım 2009
Mesajlar
192
Excel Vers. ve Dili
365 ProPlus TR
Altın Üyelik Bitiş Tarihi
17-11-2026
Merhaba,
Excel'de A1 ile D10 arasındaki hücreleri masaüstüne imza.jpg olarak nasıl kaydettirebilirim?
 

turist

Destek Ekibi
Destek Ekibi
Katılım
18 Kasım 2009
Mesajlar
5,102
Excel Vers. ve Dili
2013 64Bit
English
Sorunuz "Fonksiyon Soruları" başlığı altında, ancak; Fonksiyon ve formüllerle istediğinizi yapmak mümkün değil.
Makro ile çözüm isterseniz; aşağıdaki kodu Sayfanızda deneyin.
Kod:
Sub ResimGonder()
Dim gorunum, yol As String
gorunum = ActiveWindow.View
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = False
Set Sh = ActiveSheet
yol = CreateObject("WScript.Shell").specialfolders("Desktop") & "\imza.jpg"
boyut = 100 / Sh.Parent.Windows(1).Zoom
Set alan = Sh.[A1:D10]
alan.CopyPicture xlPrinter
Set resim = Sh.ChartObjects.Add(0, 0, alan.Width * boyut, alan.Height * boyut)
resim.Chart.Paste
resim.Chart.Export yol, "jpg"
resim.Delete
ActiveWindow.View = gorunum
Application.ScreenUpdating = True
End Sub
 

bthn35

Altın Üye
Katılım
12 Kasım 2009
Mesajlar
192
Excel Vers. ve Dili
365 ProPlus TR
Altın Üyelik Bitiş Tarihi
17-11-2026
Merhaba,
Teşekkür ederim, masaüstüne atıyor ancak resim bembeyaz çıkıyor ve içeriği yok.

 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,800
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
Birde bu kodu dene

Rich (BB code):
Option Explicit
Option Compare Text

#If Win64 Then
Private Declare PtrSafe Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Private Declare PtrSafe Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare PtrSafe Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Private Declare PtrSafe Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
#Else
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As uPicDesc, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Private Declare Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long

#End If

#If VBA7 Then
#Else
#End If

Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type uPicDesc
Size As Long
Type As Long
hPic As Long
hPal As Long
End Type


Const CF_BITMAP = 2
Const CF_ENHMETAFILE = 14
Const IMAGE_BITMAP = 0
Const LR_COPYRETURNORG = &H4

Function PastePicture(Optional lXlPicType As Long = xlPicture) As IPicture

Dim h As Long, hPicAvail As Long, hPtr As Long, hPal As Long, lPicType As Long, hCopy As Long
lPicType = IIf(lXlPicType = xlBitmap, CF_BITMAP, CF_ENHMETAFILE)
hPicAvail = IsClipboardFormatAvailable(lPicType)
If hPicAvail <> 0 Then
h = OpenClipboard(0&)
If h > 0 Then
hPtr = GetClipboardData(lPicType)
If lPicType = CF_BITMAP Then
hCopy = CopyImage(hPtr, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG)
Else
hCopy = CopyEnhMetaFile(hPtr, vbNullString)
End If
h = CloseClipboard
If hPtr <> 0 Then Set PastePicture = CreatePicture(hCopy, 0, lPicType)
End If
End If

End Function

Private Function CreatePicture(ByVal hPic As Long, ByVal hPal As Long, ByVal lPicType) As IPicture
Dim r As Long, uPicInfo As uPicDesc, IID_IDispatch As GUID, IPic As IPicture

With IID_IDispatch
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With
With uPicInfo
.Size = Len(uPicInfo)
.Type = IIf(lPicType = CF_BITMAP, 1, 4)
.hPic = hPic
.hPal = IIf(lPicType = CF_BITMAP, hPal, 0)
End With

r = OleCreatePictureIndirect(uPicInfo, IID_IDispatch, True, IPic)
If r <> 0 Then Debug.Print "Create Picture: " & fnOLEError(r)
Set CreatePicture = IPic

End Function

Private Function fnOLEError(lErrNum As Long) As String

Select Case lErrNum
Case &H80004004
fnOLEError = " Aborted"
Case &H80070005
fnOLEError = " Access Denied"
Case &H80004005
fnOLEError = " General Failure"
Case &H80070006
fnOLEError = " Bad/Missing Handle"
Case &H80070057
fnOLEError = " Invalid Argument"
Case &H80004002
fnOLEError = " No Interface"
Case &H80004001
fnOLEError = " Not Implemented"
Case &H8007000E
fnOLEError = " Out of Memory"
Case &H80004003
fnOLEError = " Invalid Pointer"
Case &H8000FFFF
fnOLEError = " Unknown Error"
Case &H0
fnOLEError = " Success!"
End Select

End Function

Sub kayit_yap()

Dim Dosya_Sistemi As Object, Dosya_Adı As String, masa As String
Dim say, obMetafile As Long, lPicType As Long, oPic

masa = CreateObject("wscript.Shell").SpecialFolders.Item("Desktop")

say = CreateObject("Scripting.FileSystemObject").GetFolder(masa).Files.Count + 1
Dosya_Adı = masa & "\imza " & say & ".jpg"
'lPicType = IIf(obMetafile, xlPicture, xlPicture) 'ofis 2007 için
lPicType = IIf(obMetafile, xlPicture, xlBitmap) 'ofis 2003 için
Range("a1:d10").CopyPicture Appearance:=xlScreen, Format:=xlBitmap

Set oPic = PastePicture(lPicType)

SavePicture oPic, Dosya_Adı

MsgBox Dosya_Adı & "  klasörüne resim ekleme işi yapıldı"

End Sub
 

bthn35

Altın Üye
Katılım
12 Kasım 2009
Mesajlar
192
Excel Vers. ve Dili
365 ProPlus TR
Altın Üyelik Bitiş Tarihi
17-11-2026
Maalesef hata veriyor.


 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,800
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
kod:

Kod:
Sub resim_kaydet()

Dim objTemp As Object
Dim chtMyChart As Chart

Range("A1:D10").Copy

Set objTemp = ActiveSheet.Shapes.AddShape(1, 1, 1, 1, 1)
objTemp.Select
ActiveSheet.Paste
objTemp.Delete

klasor = ThisWorkbook.Path
say = CreateObject("Scripting.FileSystemObject").GetFolder(klasor).Files.Count + 1
dosya = klasor & "\Resim " & say & ".jpg"


With Selection
.CopyPicture 1, 2
Set chtMyChart = ActiveSheet.ChartObjects.Add(1, 1, .Width, .Height).Chart
With chtMyChart
.Paste
.Export dosya
.Parent.Delete
End With
.Delete
End With
MsgBox dosya & Chr(10) & " olarak kaydedildi.", , "UAYRI"

Set objTemp = Nothing
End Sub
 
Üst