?
Solved

Windows Clipboard issue

Posted on 2014-12-19
19
Medium Priority
?
295 Views
Last Modified: 2014-12-22
Hello,

From VBScript, I use Internet Explorer to copy a network path to my Windows clipboard.  Due to a recent Windows security update, it does not work now.  Rather than figure out what security update caused it, I just want to stop using IE for this function.  Is there a shell command or something like that I can use?  Here's my code.
Sub CommandButtonClipBoard_Click()

    On Error Resume Next

Dim strCopy
Dim objIE

JobYear = cstr(Year(Item.UserProperties("JobInitiatedDate")))

strCopy = "\\TGPS13VM1\drawing$\Jobs-"+JobYear+"\"+Item.UserProperties("JobNumber")+" "+Item.UserProperties("JobName")

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", strCopy
objIE.Quit

End Sub

Open in new window


Thanks,
Joel
0
Comment
Question by:Genius123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 2
  • +1
19 Comments
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 40510432
Have you tried this?
a. Open Internet Explorer.
b. Click on Tools.
c. Click on Internet Options.
d. Under Security tab, Click on Internet and then click on Custom level.
e. Scroll down and under Scripting, you will find an option “Allow Programmatic clipboard access”.
f. Under that click on Enable and click OK and again OK.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40510729
You should try the htmfile object
Set oHTML = CreateObject("htmlfile")

Open in new window

0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40510766
Using clip maybe an option as well, I don't get any security warnings with that. Can you try:

...
strCopy = "\\TGPS13VM1\drawing$\Jobs-"+JobYear+"\"+Item.UserProperties("JobNumber")+" "+Item.UserProperties("JobName")

Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn
oIn.WriteLine strCopy
oIn.Close
...

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Genius123
ID: 40513250
Thanks Gerwin.  I get an error.  Could you help further?

Object required: WshShell.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513524
Oops, missed a line copying from my example. Can you try again? The missin CreateObject is added below.

...
strCopy = "\\TGPS13VM1\drawing$\Jobs-"+JobYear+"\"+Item.UserProperties("JobNumber")+" "+Item.UserProperties("JobName")

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn
oIn.WriteLine strCopy
oIn.Close
...

Open in new window

0
 

Author Comment

by:Genius123
ID: 40513545
Thanks for your help on this.  Now I get this error on this line:

Set oExec = WshShell.Exec("clip")

The system cannot find the specified file.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513561
Hmm, this is a Windows7 machine you are working on, right? I am and clip.exe is in the path. But if it is not, you can do this:

Set oExec = WshShell.Exec("%SYSTEMROOT%\system32\clip.exe")
0
 

Author Comment

by:Genius123
ID: 40513572
Yes, I'm on Win 7 64 bit.  I tried that line and it gives me the same error.  Any other ideas?
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513656
Strange, I have WIn7 64 bit as well, can you try and find "clip.exe" on a cmd prompt"

cd %SYSTEMROOT%
dir /a /s clip.exe

and post your results?
0
 

Author Comment

by:Genius123
ID: 40513681
Here's what I get.  See attached.
Document1.pdf
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40513697
you might need to run the clip.exe from the syswow64 directory.
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 2000 total points
ID: 40513701
Looks OK to me (I have the exact same). Maybe some weird path setting.

Can you try and see if clip itself is working:

C:\Windows\system32>echo HELLO | clip

Then paste in some other application, you should paste 'HELLO'.

Then, if that works, try:
Set oExec = WshShell.Exec("C:\Windows\system32\clip.exe") 

Open in new window


Also, try my test script:
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Windows\system32\clip.exe")
Set oIn = oExec.stdIn
oIn.WriteLine "HELLO Genius123"
oIn.Close

Open in new window


Save as somefile.vbs and run it, after which you should be able to past 'Hello Genius123' somewhere.

Tip: you may want to remove some personal info from your pdf writer or Word :)
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513721
>> you might need to run the clip.exe from the syswow64 directory.
It is running just fine from %SYSTEMROOT%\system32 for me ;)
0
 

Author Comment

by:Genius123
ID: 40513856
I tried both and here's what I get.  See attached.
Document2.pdf
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513888
Instead of posting PDF's you can also just paste the text from your CMD prompt ;)

You must not copy the complete text I pasted above, that will not work.

- open a cmd prompt
- type: cd \windows\system32
- type: echo HELLO | clip
- open notepad and paste (ctrl-v) there.

Does that work?
0
 

Author Comment

by:Genius123
ID: 40513917
Yes!  That worked.  It also works from the script.  Thanks very much for your help :-)

Just so it's documented, this is the final answer:

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Windows\system32\clip.exe")
Set oIn = oExec.stdIn
oIn.WriteLine "HELLO Genius123"
oIn.Close
0
 

Author Closing Comment

by:Genius123
ID: 40513920
Yes!  That worked.  It also works from the script.  Thanks very much for your help :-)
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513925
Great, glad we could help you out ;)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question