As title.
Referred to a lot of information, the tool is the key wizard.
Method 1: DLL loading
Source; www.vbforums.com/showthread….
This DLL can set and read the clip. Drag the DLL into the plugin directory of the Sprite and call it.
Set text and read text successfully, but do not know how to do image; To give up.
Method 2: The Desert? Not tested.
Methods 3:www.irfanview.com/64bit.htm download software, bring CMD tools, the following can keep clip photos to the folder, as follows
None of the above has solved the problem completely, I need to copy the picture to clipboard.
Method 4: Return to the original archaeological post. There is a bug in IE about copying pictures from the original web version. Run Execommand to copy them to the user clipboard.
JS code online many, VB code poor, finally fix, as follows, the principle is similar to JS, their interpretation:
The only copy of the code on the Internet, several copies of the time to give a thumbs-up26996579 &qq.com
Function SetCLBPIC(PicFileSpec)
Set fso = CreateObject("Scripting.FileSystemObject") Dim HtmlPath, StrDefine the variable HtmlPath ="C:\tmp\copy-img-tmp.html" 'Temporary file path, modifiable (more reliable from environment variable) Str = "
imgid' name='image' src='"& PicFileSpec &"' /> " If fso.FileExists(HtmlPath) Then fso.DeleteFile HtmlPath, true 'Delete possible HTML End If Call GenerateNewHtml(HtmlPath, Str)'written in HTML Str Set ie = CreateObject (" InternetExplorer. Application ")'Create the IE object IE. Navigate HtmlPath'ie.visible=true Do While ie.ReadyState <> 4 Loop iL = ie.Document.all.Length For I = 1 To iL On Error Resume Next strTmp = ie.Document.all(I).getAttribute("name") If InStr(1, strTmp, "image", vbTextCompare) > 0 Then iIndex = I Exit For 'found then break
End If
Next
Set controlRange = ie.Document.body.createControlRange()
'Call controlRange.Add( ie.Document.getElementById("imgid")) Call controlRange.Add( ie.Document.all(iIndex)) Call controlRange.execCommand("Copy") Delay(100) ie.Quit 'IE Object ExitSet ie = nothing 'Release fso.DeleteFile HtmlPath, true'Strong deleteSet fso = nothing 'Release End Function'Generate HTML file Sub GenerateNewHtml(HtmlsPath, tStr)Set fso = CreateObject("Scripting.FileSystemObject")
'Set objFile = fso.CreateTextFile(HtmlsPath) 'Create a fileSet ttfile = fso.OpenTextFile(HtmlsPath, 2, True) Write tStr ttfile.Close End Sub Call SetCLBPIC("C:\ TMP \a.jpg")Copy the code
Whisper it quietly, master usually leave two hands, even if you copy the above code may not work, because there are two obstacles.
- Although IE has a bug, but they are also very smart, the first IE will remind you to use your Clipboard, need to click to run. Obviously not convenient, I can’t click every time and need to turn on is.visible =true to see… How to solve it is as follows:
- I’m not done yet. When you run it, you get an error again saying content is banned and needs to be opened here.
- Wait, it’s not over yet. It still won’t work when you run it… Need to look at the little star, prompt you to restart the computer to take effect…
So far, the perfect solution… Too many pits!!