Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getsavefilename - to specified path 1

Status
Not open for further replies.

cutestuff

Technical User
Sep 7, 2006
162
CA
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.
 
it'd be a lot easier if you use "FileSystemObject" which is part of the "Microsoft Scripting Runtime" Library.

when in design mode of a module, select Tools-References, navigate to Microsoft Scripting Runtime and check the checkbox then click OK.

use MoveFile to rename a file

Dim fso As New FileSystemObject
fso.MoveFile "c:\test.txt", "c:\test1.txt"

PaulF
 
thank you so very much for pointing me in the right direction!
it seems as though it's got a lot of other useful functions I can use!
if i could give you 100 stars I would!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top