Geoff Codd
Registered User.
- Local time
- Today, 00:19
- Joined
- Mar 6, 2002
- Messages
- 190
Hi there,
I am using the following code to zip files.
Function Zip_AvE_Databases()
DoCmd.SetWarnings False
Dim vDestination As String
Dim vReporting
Dim vReporting_Entity As Variant
Dim vReporting_Folder As Variant
Dim vFile_Long As Variant
Dim vFile_Short As Variant
Dim sWinZip As String
Dim sZipFile As String
Dim sFileToZip As String
vDestination = "\\Gblon1wins1\shares\UK - FIN\FIN_RevOps\Source_Control_Reports\" 'Destination folder
Set vReporting = CurrentDb().OpenRecordset("tblAvE_Templates_Required")
Do Until vReporting.EOF
DoCmd.OpenForm "frmPlease_Wait_Message", acNormal, "", "", acReadOnly, acNormal
DoCmd.RepaintObject acForm, "frmPlease_Wait_Message"
vReporting_Entity = vReporting!reporting
vReporting_Folder = vReporting!Folder
vFile_Long = vDestination + vReporting_Folder + "\AvE_" + vReporting_Entity
vFile_Short = GetShortName(vFile_Long)
sWinZip = "C:\Program Files\WinZip\WinZip32.exe" 'Location of the WinZip program
sZipFile = vFile_Short & ".zip"
sFileToZip = vFile_Short & ".mdb"
Call Shell(sWinZip & " -a " & sZipFile & " " & sFileToZip, vbHide)
vReporting.MoveNext
Loop
vReporting.Close
DoCmd.Close acForm, "frmPlease_Wait_Message"
DoCmd.SetWarnings True
End Function
Option Compare Database
Option Explicit
Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Public Function GetShortName(ByVal sLongFileName As String) As String
Dim lRetVal As Long, sShortPathName As String, iLen As Integer
'Set up buffer area for API function call return
sShortPathName = Space(255)
iLen = Len(sShortPathName)
'Call the function
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
'Strip away unwanted characters.
GetShortName = Left(sShortPathName, lRetVal)
End Function
But I am not getting the short file name returned, I have stepped through the code and each time the file name is returned as ""
Any ideas anyone, all help appreciated.
Thanks
Geoff
I am using the following code to zip files.
Function Zip_AvE_Databases()
DoCmd.SetWarnings False
Dim vDestination As String
Dim vReporting
Dim vReporting_Entity As Variant
Dim vReporting_Folder As Variant
Dim vFile_Long As Variant
Dim vFile_Short As Variant
Dim sWinZip As String
Dim sZipFile As String
Dim sFileToZip As String
vDestination = "\\Gblon1wins1\shares\UK - FIN\FIN_RevOps\Source_Control_Reports\" 'Destination folder
Set vReporting = CurrentDb().OpenRecordset("tblAvE_Templates_Required")
Do Until vReporting.EOF
DoCmd.OpenForm "frmPlease_Wait_Message", acNormal, "", "", acReadOnly, acNormal
DoCmd.RepaintObject acForm, "frmPlease_Wait_Message"
vReporting_Entity = vReporting!reporting
vReporting_Folder = vReporting!Folder
vFile_Long = vDestination + vReporting_Folder + "\AvE_" + vReporting_Entity
vFile_Short = GetShortName(vFile_Long)
sWinZip = "C:\Program Files\WinZip\WinZip32.exe" 'Location of the WinZip program
sZipFile = vFile_Short & ".zip"
sFileToZip = vFile_Short & ".mdb"
Call Shell(sWinZip & " -a " & sZipFile & " " & sFileToZip, vbHide)
vReporting.MoveNext
Loop
vReporting.Close
DoCmd.Close acForm, "frmPlease_Wait_Message"
DoCmd.SetWarnings True
End Function
Option Compare Database
Option Explicit
Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Public Function GetShortName(ByVal sLongFileName As String) As String
Dim lRetVal As Long, sShortPathName As String, iLen As Integer
'Set up buffer area for API function call return
sShortPathName = Space(255)
iLen = Len(sShortPathName)
'Call the function
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
'Strip away unwanted characters.
GetShortName = Left(sShortPathName, lRetVal)
End Function
But I am not getting the short file name returned, I have stepped through the code and each time the file name is returned as ""
Any ideas anyone, all help appreciated.
Thanks
Geoff