excel怎么弄
Excel能够实际应用到工作中,解决80%的工作任务够用即可。不是我凡尔赛,按照我的方法学习,一个月的时间达到这个程度不成问题,下面大家详细说说。自我介绍:20年毕业,大学金融专业,一毕业就在北京某...
2024.11.20思路与之前发送信息一样,将“文件”放入剪贴板中,就可以用CTRL+V,粘贴到微信信息框中实现发送文件了。
表格式样
可是VBA 自带函数FileCopy 并不产生文件复制到剪贴板的效果,需调用Window API接口操作,代码如下。(来自EXCEL HOME论坛)
Private declare PtrSafe Function RegisterClipboardFormat Lib "user32.dll" Alias "RegisterClipboardFormatW" (ByVal lpString As LongPtr) As LongPrivate declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As LongPtr) As LongPrivate declare PtrSafe Function CloseClipboard Lib "user32" () As LongPrivate declare PtrSafe Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As LongPtr) As LongPrivate declare PtrSafe Function EmptyClipboard Lib "user32" () As LongPrivate declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtrPrivate declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As LongPtr) As LongPrivate declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal flags As Long, ByVal Size As Long) As LongPtrPrivate declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal hpvDest As LongPtr, ByVal hpvSource As LongPtr, ByVal cbCopy As Long)‘API函数定义结束Private Const CF_HDROP As Long = 15&Private Const DROPEFFECT_COPY As Long = 1Private Const DROPEFFECT_MOVE As Long = 2Private Const GMEM_ZEROINIT As Long = &H40Private Const GMEM_MOVEABLE As Long = &H2Private Const GMEM_DDESHARE As Long = &H2000‘结构定义开始Private Type POINTAPIX As LongY As LongEnd TypePrivate Type dropFilespFiles As Longpt As POINTAPIfNC As LongfWide As LongEnd Type‘结构定义结束Public declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)上面的代码都是 API函数的定义所需的(64位的VBE环境)。下面代码是将文件复制到剪贴板。
Sub clipCopyFile(FileList As Variant)Dim uDropEffect As Long, I As LongDim dropFilesAs dropFilesDim uGblLen As Long, uDropFilesLenAs LongDim hGblFilesAs LongPtrDim hGblEffectAs LongPtrDim mPtrAs LongPtrDim FNameAs StringIf OpenClipboard(0) ThenEmptyClipboardFName = Trim(FileList)If Len(FName) ThenuDropEffect = RegisterClipboardFormat(StrPtr("Preferred DropEffect"))hGblEffect = GlobalAlloc(GMEM_ZEROINIT Or GMEM_MOVEABLE Or GMEM_DDESHARE, Len(uDropEffect))mPtr = GlobalLock(hGblEffect)I = DROPEFFECT_COPYCopyMemory mPtr, VarPtr(I), Len(I)GlobalUnlock hGblEffectSetClipboardData uDropEffect, hGblEffectuDropFilesLen = LenB(dropFiles)With dropFiles.pFiles = uDropFilesLen.fWide = CLng(True)End WithuGblLen = uDropFilesLen + LenB(FName) + 8hGblFiles = GlobalAlloc(GMEM_ZEROINIT Or GMEM_MOVEABLE Or GMEM_DDESHARE, uGblLen)mPtr = GlobalLock(hGblFiles)CopyMemory mPtr, VarPtr(dropFiles), uDropFilesLenmPtr = mPtr + uDropFilesLenhGblEffect = StrPtr(FName)I = LenB(FName)CopyMemory mPtr, hGblEffect, IGlobalUnlock hGblFilesSetClipboardData CF_HDROP, hGblFilesEnd IfCloseClipboardEnd IfEnd Sub此clipCopyFile过程只处理单个的文件(已被我修改了),需要一次处理多个文件的,可去EXCEL HOME论坛查看源码。
微信发文件代码:
Sub 发文件()Set ws = CreateObject("wscript.shell")ws.SendKeys "^%w"For I = 2 To Cells(Rows.Count, 1).End(xlUp).Rowws.Run "mshta vbscript:ClipboardData.SetData(""Text""," & Chr(34) & Cells(I, 1) & Chr(34) & ")(close)", 0, TrueSleep 300ws.SendKeys "^f"Sleep 1000ws.SendKeys "^v"Sleep 500ws.SendKeys "{ENTER}"Sleep 500ws.Run "mshta vbscript:ClipboardData.SetData(" & Chr(34) & "Text" & Chr(34) & "," & Chr(34) & Cells(I, 2) & Chr(34) & ")(close)", 0, TrueSleep 500ws.SendKeys "^v"Sleep 500ws.SendKeys "{ENTER}"wjName = Cells(I, 3).ValueclipCopyFile wjNamews.SendKeys "^v"Sleep 500ws.SendKeys "{ENTER}"Next ISet ws = NothingEnd SubExcel能够实际应用到工作中,解决80%的工作任务够用即可。不是我凡尔赛,按照我的方法学习,一个月的时间达到这个程度不成问题,下面大家详细说说。自我介绍:20年毕业,大学金融专业,一毕业就在北京某...
2024.11.20密码:12341. 在中毒的U盘里创建一个新的记事本把以下内容复制到新的记事本中,并保存文件,命名为01.reg:Windows Registry Editor Version 5.00 [HKEY_...
2024.11.23当我们把重要文件加密后,可以有效地保护文件数据安全,那么文件加密后该怎么打开使用呢?下面我们就一起来了解一下吧。EFS加密作为Windows系统提供的文件加密方法,EFS加密并不需要密码。在我们使用加...
2024.11.22在数据分析中常常需要快速的制造一个随机数据表格。所用工具为excel。而数据一个一个手工录取太麻烦,并且数据的分布也不美观。这时可以考虑用随机函数来快速制造。Excel如何快速生成指定区间的随机数,平...
2024.11.22CSV文件是一种数据文件,正常情况下,我们可以直接在Excel表格中打开CSV文件,不过有时也会出现乱码,很多人不知道该如何解决。针对此种情况,本文详细介绍了解决方法,有需要的用户可以参考。Excel...
2024.11.22