Using SHCOPY and wanting to limit file types

RyanB

Registered User.
Local time
Today, 10:06
Joined
Jul 13, 2004
Messages
53
Hi,

I'm using the SHCOPY code for moving files into my database, only problem is I only want .PDF files to be displayed, i've searched google and all and can't find any reference on how to do it.

Anyone know?

Cheers,


Code:
Option Compare Database
Option Explicit

' Shcopy sample from BlackBeltVB.com
' http://blackbeltvb.com
'
' Written by Matt Hart
' Copyright 1999 by Matt Hart
'
' This software is FREEWARE. You may use it as you see fit for
' your own projects but you may not re-sell the original or the
' source code. Do not copy this sample to a collection, such as
' a CD-ROM archive. You may link directly to the original sample
' using "http://blackbeltvb.com/shcopy.htm"
'
' No warranty express or implied, is given as to the use of this
' program. Use at your own risk.
'
' This program shows how to implement the SHFileOperation API.
' You can use it to delete, move, or copy multiple or single files,
' and it can send files to the recycle bin.

Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Type

Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long

' // Shell File Operations

Const FO_MOVE = &H1
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_RENAME = &H4
Const FOF_MULTIDESTFILES = &H1
Const FOF_CONFIRMMOUSE = &H2
Const FOF_SILENT = &H4 ' don't create progress/report
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMATION = &H10 ' Don't prompt the user.
Const FOF_WANTMAPPINGHANDLE = &H20 ' Fill in SHFILEOPSTRUCT.hNameMappings
' Must be freed using SHFreeNameMappings
Const FOF_ALLOWUNDO = &H40
Const FOF_FILESONLY = &H80 ' on *.*, do only files - not directories
Const FOF_SIMPLEPROGRESS = &H100 ' means don't show names of files
Const FOF_NOCONFIRMMKDIR = &H200 ' don't confirm making any needed dirs

Const PO_DELETE = &H13 ' printer is being deleted
Const PO_RENAME = &H14 ' printer is being renamed
Const PO_PORTCHANGE = &H20 ' port this printer connected to is being changed
' if this id is set, the strings received by
' the copyhook are a doubly-null terminated
' list of strings. The first is the printer
' name and the second is the printer port.
Const PO_REN_PORT = &H34 ' PO_RENAME and PO_PORTCHANGE at same time.
'******************************
'Created by Andrew Frankum *
'******************************

Private Sub butclose_Click()

DoCmd.Close

End Sub

Private Sub cmdSelect_Click()
Me.CommonDialog3.initdir = "C:\" ' This Directory can be set to any directory
Me.CommonDialog3.showopen ' Opens the Select File Dialog Box
Me.txtcopy = CommonDialog3.filename ' Sends Filename to text box in Form

End Sub



Private Sub Command10_Click()
Dim arfile As String
Dim savepath As String
Dim lResult As Long, SHF As SHFILEOPSTRUCT

arfile = textAR.Value
savepath = "C:\test\"
SHF.hwnd = hwnd
SHF.wFunc = FO_COPY
SHF.pFrom = txtcopy
SHF.pTo = (savepath & "AR" & arnum & ".pdf")
SHF.fFlags = FOF_FILESONLY
lResult = SHFileOperation(SHF)
If lResult Then
MsgBox "Error occurred!", vbInformation, "SHCOPY"
End If
Debug.Print
txtPath = SHF.pTo
MsgBox "File has been successfully copied to the path displayed below", vbInformation, "Copied"
DoCmd.Close
End Sub

Private Sub txtPath_Click()
Application.FollowHyperlink ' Opens Filename using Windows
End Sub
 

Users who are viewing this thread

Back
Top Bottom