Discussion:
Formate von DataObject
(zu alt für eine Antwort)
Thomas Wiedmann
2009-08-10 07:06:58 UTC
Permalink
Hallo,

das Auslesen von Text aus der Zwischenablage ist bei folgendem Statement
gescheitert:

Dim clipboard As DataObject
Set clipboard = New DataObject
clipboard.GetFromClipboard

If clipboard.GetFormat(1)
...

Konkret: clipboard.GetFormat(1) lieferte False. Es war aber definitiv Text
in der Zwischenablage, den ich problemlos in einen Nur-Text-Editor einfügen
konnte.

Welche Codes (<code> sind denn für die Methode DataObject.GetFormat(<code>)
für Text-Formate außer "1" sonst noch verfügbar? In der Hilfe zu dieser
Methode fand ich darauf zumindest keinen konkreten Hinweis.


Thomas Wiedmann
Christian Freßdorf
2009-08-10 07:56:58 UTC
Permalink
Hallo Thomas,
Post by Thomas Wiedmann
If clipboard.GetFormat(1)
soweit ich mich erinner greift GetFormat nur dann sauber, wenn es vorher
mit SetFormat eingestellt wurde.
Diese Methode ist auch nur schlecht dokumentiert und auch nicht zur Abfrage
des Clipboard-Formats geeignet.
--
Gruß Christian
~~~~~~~~~~~~
Antworten / Rückmeldungen nur in die NG!
Co-Autor von »Microsoft Word-Programmierung.
Das Handbuch« (MS Press)
Thomas Wiedmann
2009-08-10 16:38:53 UTC
Permalink
Post by Christian Freßdorf
soweit ich mich erinner greift GetFormat nur dann sauber, wenn es vorher
mit SetFormat eingestellt wurde.
Zu DataObject finde ich keine Methode SetFormat (Nicht an meiner
Objekt-Bezeichnung clipboard stören - hab ich hier als Instanz von
DataObject deklariert).


Thomas Wiedmann
Christian Freßdorf
2009-08-10 18:06:13 UTC
Permalink
Hallo Thomas,
Post by Thomas Wiedmann
Zu DataObject finde ich keine Methode SetFormat (Nicht an meiner
Objekt-Bezeichnung clipboard stören - hab ich hier als Instanz von
DataObject deklariert).
sorry, wird bei SetText mitangegeben.

Es scheint so zu sein, dass es nur dann sauber funktioniert, wenn man auch
per SetText und Format diesen mitangibt.
Ansonsten funktioniert es hier mit markiertem Text aus der Mail auch nicht.

Eine funktionierende Lösung mit dem ClipBoard-API bekomme ich auch nicht
hin.

Gruß
Christian
Thomas Gahler
2009-08-11 04:55:03 UTC
Permalink
Hallo Thomas
Guten Tag Christian


Habe ich richtig verstande, dass ihr prüfen wollt, ob in der Ziwchenablage
Text drin ist? Das mache ich mit folgendem Code.


' --------- --------- --------- --------- ---------
Option Explicit

'API zum abfragen des Formats in der Zwischenablage.
Private Declare Function IsClipboardFormatAvailable Lib "user32" _
(ByVal wFormat As ClipboardFormatConstants) _
As Long

'Konstanten zum API definieren.
Public Enum ClipboardFormatConstants
CF_TEXT = 1
CF_BITMAP = 2
CF_METAFILEPICT = 3
CF_SYLK = 4
CF_DIF = 5
CF_TIFF = 6
CF_OEMTEXT = 7
CF_DIB = 8
CF_PALETTE = 9
CF_PENDATA = 10
CF_RIFF = 11
CF_WAVE = 12
CF_UNICODETEXT = 13
CF_ENHMETAFILE = 14
CF_HDROP = 15
End Enum

Public Function funcIsClipboardFormatAvailable( _
ByVal EFormat As ClipboardFormatConstants) _
As Boolean

funcIsClipboardFormatAvailable =
CBool(IsClipboardFormatAvailable(EFormat))
End Function
' --------- --------- --------- --------- ---------
--
Thomas Gahler
MVP für Word
Co-Autor von »Microsoft Word-Programmierung.
Das Handbuch« (MS Press)


- Windows XP (SP3), Office XP (SP3)
Christian Freßdorf
2009-08-11 07:15:27 UTC
Permalink
Hi

hier noch u.a. eine Erklärung, wie Windows mit der Zwischenablage umgeht
und warum Text nicht immer wirklich Text ist:

http://www.vbarchiv.net/workshop/workshop_25-die-zwischenablage-im-griff.html

HTH
Christian
Trevor Robertson
2010-10-29 09:44:08 UTC
Permalink
http://www.mrexcel.com/forum/showthread.php?t=505254
Post by Thomas Wiedmann
Hallo,
das Auslesen von Text aus der Zwischenablage ist bei folgendem Statement
Dim clipboard As DataObject
Set clipboard = New DataObject
clipboard.GetFromClipboard
If clipboard.GetFormat(1)
...
Konkret: clipboard.GetFormat(1) lieferte False. Es war aber definitiv Text
in der Zwischenablage, den ich problemlos in einen Nur-Text-Editor einf?gen
konnte.
Welche Codes (<code> sind denn f?r die Methode DataObject.GetFormat(<code>)
f?r Text-Formate au?er "1" sonst noch verf?gbar? In der Hilfe zu dieser
Methode fand ich darauf zumindest keinen konkreten Hinweis.
Thomas Wiedmann
Post by Christian Freßdorf
Hallo Thomas,
soweit ich mich erinner greift GetFormat nur dann sauber, wenn es vorher
mit SetFormat eingestellt wurde.
Diese Methode ist auch nur schlecht dokumentiert und auch nicht zur Abfrage
des Clipboard-Formats geeignet.
--
Gru? Christian
~~~~~~~~~~~~
Antworten / R?ckmeldungen nur in die NG!
Co-Autor von ?Microsoft Word-Programmierung.
Das Handbuch? (MS Press)
Post by Thomas Wiedmann
Zu DataObject finde ich keine Methode SetFormat (Nicht an meiner
Objekt-Bezeichnung clipboard st?ren - hab ich hier als Instanz von
DataObject deklariert).
Thomas Wiedmann
Post by Christian Freßdorf
Hallo Thomas,
sorry, wird bei SetText mitangegeben.
Es scheint so zu sein, dass es nur dann sauber funktioniert, wenn man auch
per SetText und Format diesen mitangibt.
Ansonsten funktioniert es hier mit markiertem Text aus der Mail auch nicht.
Eine funktionierende L?sung mit dem ClipBoard-API bekomme ich auch nicht
hin.
Gru?
Christian
Post by Christian Freßdorf
Hallo Thomas
Guten Tag Christian
Habe ich richtig verstande, dass ihr pr?fen wollt, ob in der Ziwchenablage
Text drin ist? Das mache ich mit folgendem Code.
' --------- --------- --------- --------- ---------
Option Explicit
'API zum abfragen des Formats in der Zwischenablage.
Private Declare Function IsClipboardFormatAvailable Lib "user32" _
(ByVal wFormat As ClipboardFormatConstants) _
As Long
'Konstanten zum API definieren.
Public Enum ClipboardFormatConstants
CF_TEXT = 1
CF_BITMAP = 2
CF_METAFILEPICT = 3
CF_SYLK = 4
CF_DIF = 5
CF_TIFF = 6
CF_OEMTEXT = 7
CF_DIB = 8
CF_PALETTE = 9
CF_PENDATA = 10
CF_RIFF = 11
CF_WAVE = 12
CF_UNICODETEXT = 13
CF_ENHMETAFILE = 14
CF_HDROP = 15
End Enum
Public Function funcIsClipboardFormatAvailable( _
ByVal EFormat As ClipboardFormatConstants) _
As Boolean
funcIsClipboardFormatAvailable =
CBool(IsClipboardFormatAvailable(EFormat))
End Function
' --------- --------- --------- --------- ---------
--
Thomas Gahler
MVP f?r Word
Co-Autor von ?Microsoft Word-Programmierung.
Das Handbuch? (MS Press)
- Windows XP (SP3), Office XP (SP3)
Hi
hier noch u.a. eine Erkl?rung, wie Windows mit der Zwischenablage umgeht
http://www.vbarchiv.net/workshop/workshop_25-die-zwischenablage-im-griff.html
HTH
Christian
Submitted via EggHeadCafe - Software Developer Portal of Choice
Flat file Database with LINQ and ASP.NET jQuery Page Methods
http://www.eggheadcafe.com/tutorials/aspnet/c8c43191-c3a3-4c61-801a-2433a701f4f6/flat-file-database-with-linq-and-aspnet-jquery-page-methods.aspx
Loading...