I'm trying to set data directly to the clipboard so it can then be pasted in another program. For a test I get the current date and if it isn't xx/xx/xxxx I add zeroes where needed. Example today would be 7/21/2005 and I want 07/21/2005. I then want to send it to the clipboard, but it doesn't work.
' Code ----------------------------------------------------
Option Compare Database
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Option Explicit
Function MyModifiedDate()
Dim CurrentDate As String
Dim Slash1 As Integer, Slash2 As Integer
Dim MyMonth As String, MyDay As String, MyYear As String
Dim EndCurrentDate As String
Const CF_DSPTEXT = 8
CurrentDate = Date
Slash1 = InStr(1, CurrentDate, "/")
Slash2 = InStr((Slash1 + 1), CurrentDate, "/")
'Calculate Month
If (Len(Left(CurrentDate, Slash1 - 1)) = 1) Then
MyMonth = "0" & Left(CurrentDate, Slash1 - 1)
Else
MyMonth = Left(CurrentDate, Slash1 - 1)
End If
'Calculate Day
If (Len(Mid(CurrentDate, Slash1 + 1, ((Slash2 - Slash1) - 1))) = 1) Then
MyDay = "0" & Left(CurrentDate, Slash1 - 1)
Else
MyDay = Mid(CurrentDate, Slash1 + 1, ((Slash2 - Slash1) - 1))
End If
'Calculate Year
MyYear = Mid(CurrentDate, Slash2 + 1, ((Len(CurrentDate) - Slash2) - 1))
EndCurrentDate = MyMonth & MyDay & MyYear
OpenClipboard hWndAccessApp
EmptyClipboard
SetClipboardData CF_DSPTEXT, EndCurrentDate
CloseClipboard
End Function
' End Code -----------------------------------------------
Can anyone help me with why this doesn't set the data to the clipboard? It is totally empty.
Thank you,
Sorwen
' Code ----------------------------------------------------
Option Compare Database
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Option Explicit
Function MyModifiedDate()
Dim CurrentDate As String
Dim Slash1 As Integer, Slash2 As Integer
Dim MyMonth As String, MyDay As String, MyYear As String
Dim EndCurrentDate As String
Const CF_DSPTEXT = 8
CurrentDate = Date
Slash1 = InStr(1, CurrentDate, "/")
Slash2 = InStr((Slash1 + 1), CurrentDate, "/")
'Calculate Month
If (Len(Left(CurrentDate, Slash1 - 1)) = 1) Then
MyMonth = "0" & Left(CurrentDate, Slash1 - 1)
Else
MyMonth = Left(CurrentDate, Slash1 - 1)
End If
'Calculate Day
If (Len(Mid(CurrentDate, Slash1 + 1, ((Slash2 - Slash1) - 1))) = 1) Then
MyDay = "0" & Left(CurrentDate, Slash1 - 1)
Else
MyDay = Mid(CurrentDate, Slash1 + 1, ((Slash2 - Slash1) - 1))
End If
'Calculate Year
MyYear = Mid(CurrentDate, Slash2 + 1, ((Len(CurrentDate) - Slash2) - 1))
EndCurrentDate = MyMonth & MyDay & MyYear
OpenClipboard hWndAccessApp
EmptyClipboard
SetClipboardData CF_DSPTEXT, EndCurrentDate
CloseClipboard
End Function
' End Code -----------------------------------------------
Can anyone help me with why this doesn't set the data to the clipboard? It is totally empty.
Thank you,
Sorwen