使用環境(Access97 OS:Win2000)
何の問題も無く、コピーできます。
今回VB6は、関係ないですよね?
>エクスプローラー風ファイルコピーを作成しているのですが
>Accessのハンドルを以下のようにセットすると
>実行エラー424 (オブジェクトが必要です)と表示される。なぜ??
>
>使用環境(VB6 Access2000 OS:Win98)
>
>
>.hwnd = application.hWndAccessApp
>
>’標準モジュールへ記述
>Option Explicit
>
>Type SHFILEOPSTRUCT
>hwnd As Long
>wFunc As Long
>pFrom As String
>pTo As String
>fFlags As Integer
>fAnyOperationsAborted As Long
>hNameMappings As Long
>lpszProgressTitle As String
>End Type
>
>Declare Function SHFileOperation Lib \"SHELL32.DLL\" Alias _
>\"SHFileOperationA\" (lpFileOp As SHFILEOPSTRUCT) As Long
>
>Const FO_COPY = &H2
>Const FO_MOVE = &H1
>Const FOF_NOCONFIRMATION = &H10
>Const FOF_RENAMEONCOLLISION = &H8
>
>
>Private Sub Command1_Click()
>
>\'次の例では、ファイル\"c:\\My Documents\\Test.mdb\"を\"c:\\Test.mdb\"にコピーします。
>
>Dim stShellOp As SHFILEOPSTRUCT
>
>Const cstrSrcFile As String = \"c:\\My Documents\\Test.mdb\"
>Const cstrDstFile As String = \"c:\\Test.mdb\"
>
>With stShellOp
>.hwnd = application.hWndAccessApp
>.wFunc = FO_COPY
>.pFrom = cstrSrcFile
>.pTo = cstrDstFile
>End With
>
>If SHFileOperation(stShellOp) = 0 Then
>Beep
>MsgBox \"コピー完了しました!\"
>Else
>Beep
>MsgBox \"コピーに失敗またはキャンセルされました!\"
>End If
>
>End Sub
>
投稿日:2003/09/06 19:39
投稿者:近藤
返信 引用返信 修正 削除