I would simply like to know how to specify that I would like to store a
variable value to the clipboard so that I can paste that information to other
programs at my own discretion. Thanks!!!
I would simply like to know how to specify that I would like to store a
variable value to the clipboard so that I can paste that information to other
programs at my own discretion. Thanks!!!
Review this discussion:
http://groups.google.com/group/micro...fa7b9c45b74d89
--
Gary's Student
"tomwashere2" wrote:
> I would simply like to know how to specify that I would like to store a
> variable value to the clipboard so that I can paste that information to other
> programs at my own discretion. Thanks!!!
There's also the MSForms.DataObject you can work with.
NickHK
"tomwashere2" <tomwashere2@discussions.microsoft.com> wrote in message
news:A6AD1725-7E40-4E11-83E4-9426360854EA@microsoft.com...
> I would simply like to know how to specify that I would like to store a
> variable value to the clipboard so that I can paste that information to
other
> programs at my own discretion. Thanks!!!
Can you give me the vba code sample on how to use it?
"NickHK" wrote:
> There's also the MSForms.DataObject you can work with.
>
> NickHK
>
> "tomwashere2" <tomwashere2@discussions.microsoft.com> wrote in message
> news:A6AD1725-7E40-4E11-83E4-9426360854EA@microsoft.com...
> > I would simply like to know how to specify that I would like to store a
> > variable value to the clipboard so that I can paste that information to
> other
> > programs at my own discretion. Thanks!!!
>
>
>
VBA Help has a working example.
NickHK
"tomwashere2" <tomwashere2@discussions.microsoft.com> wrote in message
news:66A41747-826F-43A6-8FBE-984CD390ACA0@microsoft.com...
> Can you give me the vba code sample on how to use it?
>
>
>
> "NickHK" wrote:
>
> > There's also the MSForms.DataObject you can work with.
> >
> > NickHK
> >
> > "tomwashere2" <tomwashere2@discussions.microsoft.com> wrote in message
> > news:A6AD1725-7E40-4E11-83E4-9426360854EA@microsoft.com...
> > > I would simply like to know how to specify that I would like to store
a
> > > variable value to the clipboard so that I can paste that information
to
> > other
> > > programs at my own discretion. Thanks!!!
> >
> >
> >
I am trying to do the same thing. You can move data from the dataobject to
the clipboard. But as far as I can tell, you can only put data in the data
object from the clipboard or from a forms textbox.
"tomwashere2" wrote:
> Can you give me the vba code sample on how to use it?
>
>
>
> "NickHK" wrote:
>
> > There's also the MSForms.DataObject you can work with.
> >
> > NickHK
> >
> > "tomwashere2" <tomwashere2@discussions.microsoft.com> wrote in message
> > news:A6AD1725-7E40-4E11-83E4-9426360854EA@microsoft.com...
> > > I would simply like to know how to specify that I would like to store a
> > > variable value to the clipboard so that I can paste that information to
> > other
> > > programs at my own discretion. Thanks!!!
> >
> >
> >
I need to do the same thing. I found the DataObject useless, because the
only way I could find to put data in it was from the clipboard or from a
textbox.
My browser wouldn't let me access the link. Thinks it's Chat.
"Gary''s Student" wrote:
> Review this discussion:
>
> http://groups.google.com/group/micro...fa7b9c45b74d89
>
>
> --
> Gary's Student
>
>
> "tomwashere2" wrote:
>
> > I would simply like to know how to specify that I would like to store a
> > variable value to the clipboard so that I can paste that information to other
> > programs at my own discretion. Thanks!!!
After wasting a lot of time trying to find a straightforward way to do this,
I created the following subroutine that opens a workbook, puts the variable
(passed to the subroutine as an argument) in cell A1, copies that to the
clipboard, then closes the new workbook. With all the great things that can
be done with VBA and Excel, I would think there would be an easier way to do
this.
Public Sub CopyToClipboard(VariableToBeSaved)
' created by Patricia Shannon Aug. 22, 2006
' Copy variable to Clipboard
Workbooks.Add
Cells(1, 1) = VariableToBeSaved
Cells(1, 1).Copy
ActiveWorkbook.Close savechanges:=False
End Sub
In the subroutine where you need to save the variable, you would have
copytoclipboard(yourvariablehere)
"tomwashere2" wrote:
> I would simply like to know how to specify that I would like to store a
> variable value to the clipboard so that I can paste that information to other
> programs at my own discretion. Thanks!!!
Patricia,
You put text from anywhere to the clipboard with .SetText
Private Sub CommandButton2_Click()
Dim LongVal As Long
LongVal = 25
If SendToClipBoard(LongVal) = True Then ActiveSheet.Paste
End Sub
Function SendToClipBoard(AnyValue As Variant) As Boolean
Dim DatObj As DataObject
On Error GoTo Handler
Set DatObj = New DataObject
With DatObj
.SetText CStr(AnyValue), 1
.PutInClipboard
End With
SendToClipBoard = True
Exit Function
Handler:
SendToClipBoard = False
End Function
Or there is always the various Clipborad API, which all methods will resort
to in the end.
'Example from KPD-Team 1999, URL: http://www.allapi.net/
Const LR_LOADFROMFILE = &H10
Const IMAGE_BITMAP = 0
Const IMAGE_ICON = 1
Const IMAGE_CURSOR = 2
Const IMAGE_ENHMETAFILE = 3
Const CF_BITMAP = 2
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal
hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal
dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As
Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As
Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As
Long, ByVal hMem As Long) As Long
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal
wFormat As Long) As Long
Private Sub Form_Load()
Dim hDC As Long, hBitmap As Long
'Load the bitmap into the memory
hBitmap = LoadImage(App.hInstance, "c:\windows\logow.sys", IMAGE_BITMAP,
320, 200, LR_LOADFROMFILE)
If hBitmap = 0 Then
MsgBox "There was an error while loading the bitmap"
Exit Sub
End If
'open the clipboard
OpenClipboard Me.hwnd
'Clear the clipboard
EmptyClipboard
'Put our bitmap onto the clipboard
SetClipboardData CF_BITMAP, hBitmap
'Check if there's a bitmap on the clipboard
If IsClipboardFormatAvailable(CF_BITMAP) = 0 Then
MsgBox "There was an error while pasting the bitmap to the clipboard!"
End If
'Close the clipboard
CloseClipboard
'Get the picture from the clipboard
Me.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
NickHK
"Patricia Shannon" <PatriciaShannon@discussions.microsoft.com> wrote in
message news:CAEC7871-F4C2-4E84-8BA5-F913C2D5D2F7@microsoft.com...
> After wasting a lot of time trying to find a straightforward way to do
this,
> I created the following subroutine that opens a workbook, puts the
variable
> (passed to the subroutine as an argument) in cell A1, copies that to the
> clipboard, then closes the new workbook. With all the great things that
can
> be done with VBA and Excel, I would think there would be an easier way to
do
> this.
>
> Public Sub CopyToClipboard(VariableToBeSaved)
> ' created by Patricia Shannon Aug. 22, 2006
> ' Copy variable to Clipboard
>
> Workbooks.Add
> Cells(1, 1) = VariableToBeSaved
> Cells(1, 1).Copy
> ActiveWorkbook.Close savechanges:=False
>
> End Sub
>
> In the subroutine where you need to save the variable, you would have
> copytoclipboard(yourvariablehere)
> "tomwashere2" wrote:
>
> > I would simply like to know how to specify that I would like to store a
> > variable value to the clipboard so that I can paste that information to
other
> > programs at my own discretion. Thanks!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks