Macro Enabled file work on Desktop but not Network Drive - CLEAR CLIPBOARD!!

ElvisHess

Board Regular
Joined
May 4, 2006
Messages
150
Good Afternoon,

Been using the following code for years to clear the clipboard and it worked like a champ, until recently it won't work from a network drive or as an email attachment. This file works with both Excel 2010 and 2016

I get this error: Run-time error '435':
Can't find DLL entry point OpenClipboard in user32

CODE:
Option Explicit

Private Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long
Private Declare PtrSafe Function CloseClipboard Lib "user32" () As Long

Public Function ClearClipboard()
OpenClipboard (0&) 'IT BOMBS OUT ON THIS LINE WHEN FILE IS RUN OFF NETWORK DRIVE OR AS EMAIL ATTACHMENT.
EmptyClipboard
CloseClipboard
End Function

Sub ccc()
Call ClearClipboard
End Sub

Please Help!! - Thank U in Advance
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Just a guess... do you need to make the file / folder a "trusted document" or a "trusted location"?

File
Options
Trust Center
[Trust Center Settings]
Trusted Locations
 
Last edited:
Upvote 0
Did not do the Trick, Thank You - I need to figure out another way to clear my clipboard of all objects. Some security setting has been changed on our network I believe.
 
Upvote 0
I found this in another Thread and it works great from Network drive emails and other systems. The following replaces all the is above from my original. Not sure if I need Option Explicit but I left it in there.

Option Explicit

Sub EmptyCB()
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText ""
clipboard.PutInClipboard
End Sub

Sub ccc()
Call EmptyCB
End Sub
 
Upvote 0
I found this in another Thread and it works great from Network drive emails and other systems. The following replaces all the is above from my original. Not sure if I need Option Explicit but I left it in there.

Option Explicit

Sub EmptyCB()
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText ""
clipboard.PutInClipboard
End Sub

Sub ccc()
Call EmptyCB
End Sub

I would use late binding as follows so the running vbproject doesn't need to have reference to the Microsoft Forms object library.

Code:
Sub EmptyCB()
    Dim clipboard  As Object
    
    Set clipboard = CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
    clipboard.SetText ""
    clipboard.PutInClipboard
End Sub

Sub ccc()
    Call EmptyCB
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top