Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1156to1160
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Tabellenzellen in UF anzeigen
Jonathan
Hallo!
Ich hatte mal einen Code gefunden, mit dem ich einen Bereich eines Tabellenblattes inkl. Formatierungen in einer UF anzeigen konnte (der Bereich wurde vorher glaub ich als Grafik abgespeichert). Leider kann ich den Schnipsel nicht mehr finden, kann mir jemand weiter helfen?
Danke Euch!!
LG

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Tabellenzellen in UF anzeigen
01.06.2010 10:19:45
otto
Hi,
so gehts.
Option Explicit
Private Sub UserForm_Initialize()
'Copyright © 2001 by Frank Arendt-Theilen
Dim objBild As Object
Dim strPfad As String
Dim intWidth As Integer, intHeight As Integer
Dim NewChart As ChartObject
Application.ScreenUpdating = False
strPfad = Application.DefaultFilePath & "test.gif"
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Paste
Set objBild = Selection
objBild.Copy
intWidth = objBild.Width + 7
intHeight = objBild.Height + 7
Set NewChart = ActiveSheet.ChartObjects.Add(1, 1, intWidth, intHeight)
NewChart.Activate
With ActiveChart
.ChartArea.Select
.ChartArea.Border.LineStyle = 0
.Paste
.Export FileName:=strPfad, FilterName:="GIF"
End With
NewChart.Delete
objBild.Delete
Application.ScreenUpdating = True
Me.Width = intWidth + 15
Me.Height = intHeight + 30
With Image1
.Width = intWidth
.Height = intHeight
.Picture = LoadPicture(strPfad)
End With
Kill strPfad
End Sub
Die Maß must du evtl. noch anpassen.
otto
Anzeige
AW: Tabellenzellen in UF anzeigen
01.06.2010 11:35:40
Jonathan
Hey,
danke für deinen Code - klappt! Und ich hab ihn sogar verstanden! ;-)
Die Qualität der Grafik ist aber leider so schlecht, dass ich Zahlen kaum erkennen kann...
AW: Tabellenzellen in UF anzeigen
01.06.2010 14:55:09
Nepumuk
Hallo,
dann versuch es mal so:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" ( _
    ByRef PicDesc As PIC_DESC, _
    ByRef RefIID As GUID, _
    ByVal fPictureOwnsHandle As Long, _
    ByRef IPic As IPictureDisp) As Long
Declare Function CopyImage Lib "user32.dll" ( _
    ByVal handle As Long, _
    ByVal un1 As Long, _
    ByVal n1 As Long, _
    ByVal n2 As Long, _
    ByVal un2 As Long) As Long
Private Declare Function IsClipboardFormatAvailable Lib "user32.dll" ( _
    ByVal wFormat As Integer) As Long
Private Declare Function OpenClipboard Lib "user32.dll" ( _
    ByVal hWnd As Long) As Long
Private Declare Function GetClipboardData Lib "user32.dll" ( _
    ByVal wFormat As Integer) As Long
Private Declare Function EmptyClipboard Lib "user32.dll" () As Long
Private Declare Function CloseClipboard Lib "user32.dll" () As Long

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

Private Type PIC_DESC
    lngSize As Long
    lngType As Long
    lnghPic As Long
    lnghPal As Long
End Type

Private Const PICTYPE_BITMAP = 1
Private Const CF_BITMAP = 2
Private Const IMAGE_BITMAP = 0
Private Const LR_COPYRETURNORG = &H4
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"

Private Function Paste_Picture() As IPictureDisp
    
    Dim lngReturn As Long, lngCopy As Long, lngPointer As Long
    
    If IsClipboardFormatAvailable(CF_BITMAP) <> 0 Then
        lngReturn = OpenClipboard(FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption))
        If lngReturn > 0 Then
            lngPointer = GetClipboardData(CF_BITMAP)
            lngCopy = CopyImage(lngPointer, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG)
            Call CloseClipboard
            If lngPointer <> 0 Then Set Paste_Picture = Create_Picture(lngCopy, 0&, CF_BITMAP)
        End If
    End If
    
End Function

Private Function Create_Picture( _
        ByVal lnghPic As Long, _
        ByVal lnghPal As Long, _
        ByVal lngPicType As Long) As IPictureDisp

    
    Dim udtPicInfo As PIC_DESC, udtID_IDispatch As GUID
    Dim objPicture As IPictureDisp
    
    With udtID_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 udtPicInfo
        .lngSize = Len(udtPicInfo)
        .lngType = PICTYPE_BITMAP
        .lnghPic = lnghPic
        .lnghPal = lnghPal
    End With
    
    Call OleCreatePictureIndirect(udtPicInfo, udtID_IDispatch, 0&, objPicture)
    
    Set Create_Picture = objPicture
    
End Function

Public Sub Show_Sheet()
    
    Dim objPicture As IPictureDisp
    
    Call EmptyClipboard
    
    Tabelle1.Range("A1:D5").CopyPicture _
        Appearance:=xlScreen, Format:=xlBitmap 'Bereich anpassen !!!
    
    Set objPicture = Paste_Picture
    
    If Not objPicture Is Nothing Then
        UserForm1.Image1.Picture = objPicture
    Else
        MsgBox "Error - Sheet can't show in Userform", vbCritical, "Error"
    End If
    
    UserForm1.Show
    
End Sub

Gruß
Nepumuk
Anzeige

303 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige