excel选中悉氏文件名清单、自动从“a1"文件夹中查找相应的文件。
ShellExecuteA,DataObject,Clipboard,find,SendKeys
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Const SW_SHOW = 5
Sub test()
Selection.Copy
Dim MyData As DataObject
Dim sTemp As String, s As String
Set MyData = New DataObject
MyData.GetFromClipboard
sTemp = MyData.GetText
s = Replace(sTemp, vbCrLf, "")
s = Replace(s, vbTab, "")
MyData.SetText (s)
MyData.PutInClipboard
ShellExecute 0&, "find", Range("a1"笑型), _
vbNullString, vbNullString, SW_SHOW
Application.Wait (Now + TimeValue("0:00:02"睁升散))
SendKeys s &"{ENTER}"
End Sub
多看看MSDN,自己就可以摸索出来。 if (GetOpenFileName(&ofn)==TRUE) { TCHAR *pfileTCHAR szFileNames[MAX_PATH*10]TCHAR path[MAX_PATH],szFileName[MAX_PATH]szFileNames[0]=TEXT('\0'肆局悄)lstrcpyn(path, ofn.lpstrFile, ofn.nFileOffset ) path[ ofn.nFileOffset ] = TEXT('\0') if( path[lstrlen(path)-1] != TEXT('\\') ) lstrcat(path, TEXT("\\腊森")) for(pfile=ofn.lpstrFile+ofn.nFileOffset*pfile!=TEXT('\0')pfile+=lstrlen(pfile)+1) { szFileName[0]=TEXT('\0')lstrcat(szFileName, path)lstrcat(szFileName, pfile)//szFileName就是每一个带路径的文件名。 lstrcat(szFileNames, szFileName)lstrcat(szFileNames, TEXT("裂渣\n"))} MessageBox(NULL, szFileNames, TEXT("MultiSelect"), MB_OK) }欢迎分享,转载请注明来源:内存溢出
评论列表(0条)