hi,
I have a database where I'd like to do the following:
1. User will select information from several combo boxes (which will then be used as a path to a file)
2. User hits "upload" button
3. Database will retrieve information from combo boxes, open up a dialog box, save a pdf file that the user has into the path specified by the combo boxes
4. Rename the pdf file
Any ideas? I tried the getsavefilename but I couldn't quite figure out how it works. I have the following code:
----------------
Option Compare Database
Option Explicit
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias _
"GetSaveFileNameA" (pSavefilename As SAVEFILENAME) As Long
Private Type SAVEFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
Dim SaveFile As SAVEFILENAME
Dim lReturn As Long
Dim sFilter As String
SaveFile.lStructSize = Len(SaveFile)
SaveFile.hwndOwner = strform.hWnd
sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"JPEG Files (*.JPG)" & Chr(0) & "*.JPG" & Chr(0)
SaveFile.lpstrFilter = sFilter
SaveFile.nFilterIndex = 1
SaveFile.lpstrFile = String(257, 0)
SaveFile.nMaxFile = Len(SaveFile.lpstrFile) - 1
SaveFile.lpstrFileTitle = SaveFile.lpstrFile
SaveFile.nMaxFileTitle = SaveFile.nMaxFile
SaveFile.lpstrInitialDir = "C:\"
SaveFile.lpstrTitle = "Select a file using the Common Dialog DLL"
SaveFile.Flags = 0
lReturn = GetSaveFileName(SaveFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(SaveFile.lpstrFile, InStr(1, SaveFile.lpstrFile, vbNullChar) - 1))
End If
End Function
----------
I'm not sure if getsavefilename is the right function to use. All this is doing is opening the file and saving the path name. I'd like to be able to move the file to the path specified by the combo box selections.
I think I could rename the file using the "Name" command, but I'd like to figure out how to do #3 first.
Anyone have any ideas?
Thank you in advance.
I have a database where I'd like to do the following:
1. User will select information from several combo boxes (which will then be used as a path to a file)
2. User hits "upload" button
3. Database will retrieve information from combo boxes, open up a dialog box, save a pdf file that the user has into the path specified by the combo boxes
4. Rename the pdf file
Any ideas? I tried the getsavefilename but I couldn't quite figure out how it works. I have the following code:
----------------
Option Compare Database
Option Explicit
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias _
"GetSaveFileNameA" (pSavefilename As SAVEFILENAME) As Long
Private Type SAVEFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
Dim SaveFile As SAVEFILENAME
Dim lReturn As Long
Dim sFilter As String
SaveFile.lStructSize = Len(SaveFile)
SaveFile.hwndOwner = strform.hWnd
sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"JPEG Files (*.JPG)" & Chr(0) & "*.JPG" & Chr(0)
SaveFile.lpstrFilter = sFilter
SaveFile.nFilterIndex = 1
SaveFile.lpstrFile = String(257, 0)
SaveFile.nMaxFile = Len(SaveFile.lpstrFile) - 1
SaveFile.lpstrFileTitle = SaveFile.lpstrFile
SaveFile.nMaxFileTitle = SaveFile.nMaxFile
SaveFile.lpstrInitialDir = "C:\"
SaveFile.lpstrTitle = "Select a file using the Common Dialog DLL"
SaveFile.Flags = 0
lReturn = GetSaveFileName(SaveFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(SaveFile.lpstrFile, InStr(1, SaveFile.lpstrFile, vbNullChar) - 1))
End If
End Function
----------
I'm not sure if getsavefilename is the right function to use. All this is doing is opening the file and saving the path name. I'd like to be able to move the file to the path specified by the combo box selections.
I think I could rename the file using the "Name" command, but I'd like to figure out how to do #3 first.
Anyone have any ideas?
Thank you in advance.