Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1220to1224
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
Tabelle in UF anzeigen
Jonathan
Hey,
ich möchte in Excel 2007 gerne einen Bereich einer Tabelle in einer UF darstellen - mit gleicher Formatierung etc.. Habe es bisher über ein Makro gelöst, welches den Bereich als Grafik speichert und dann anzeigt. Dies dauert aber zu lange und sollte doch auch anders möglich sein, oder?
Freue mich auf Eure Antworten!

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

Betreff
Benutzer
Anzeige
AW: Tabelle in UF anzeigen
01.07.2011 07:27:50
Nepumuk
Hallo,
wozu die Grafik erst speichern? Das geht alles im Arbeitsspeicher und dauert nur ein paar Millisekunden.
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

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 Function Paste_Picture() As IPictureDisp
    
    Dim lngReturn As Long, lngCopy As Long, lngPointer As Long
    
    If IsClipboardFormatAvailable(CF_BITMAP) <> 0 Then
        lngReturn = OpenClipboard(Application.hWnd)
        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
    
    If TypeOf Selection Is Range Then
        
        Tabelle1.Range("A1:F10").CopyPicture _
            Appearance:=xlScreen, Format:=xlBitmap
        
        Set objPicture = Paste_Picture
        
        If Not objPicture Is Nothing Then
            Set UserForm1.Image1.Picture = objPicture
        Else
            MsgBox "Error - Sheet can't show in Userform", vbCritical, "Error"
        End If
        
        UserForm1.Show
        
    End If
    
End Sub

Gruß
Nepumuk
Anzeige
das geht wirklich schneller ...
01.07.2011 12:13:42
Jonathan
... die Grafik der Bilddatei ist aber leider sehr schlecht.
Vielen Dank für den umfangreichen Code!
Gibt es keine andere Möglichkeit?
AW: das geht wirklich schneller ...
02.07.2011 10:44:15
mumpel
Hallo!
Wenn Du aus einer alten Excelversion noch die "owc11" (Office Webcomponents) hast, dann installiere diese. Dann kannst Du das Spreadsheet-Element nutzen (muss dann aber bei jedem Mitanwender installiert sein).
Gruß, René

302 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige