Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change filename before saving image

Posted on 2013-11-25
1
Medium Priority
?
253 Views
Last Modified: 2013-12-02
Hello, given the code below how can I change the filename of the image? Perhaps just adding the date to the original filename to help prevent overwriting any images.
Private Sub btn_Add_Picture1_Click()
 Dim strFilter As String
     Dim strInputFileName As String

     strFilter = ahtAddFilterItem(strFilter, "JPEG Files (*.jpg)", "*.jpg")

     strInputFileName = ahtCommonFileOpenSave( _
                             Filter:=strFilter, _
                             OpenFile:=False, _
                             DialogTitle:="Save Image As...", _
                             Flags:=ahtOFN_HIDEREADONLY)
                             
                             
                             Dim strPath As String
strPath = strInputFileName

Dim strFile As String
strFile = Right(strPath, Len(strPath) - InStrRev(strPath, "\"))
                             
     If Len(strInputFileName) > 0 Then
          
     Dim fs As Object
 Dim oldPath As String, newPath As String
 oldPath = strInputFileName
 newPath = GetDefaultFilePath
 Set fs = CreateObject("Scripting.FileSystemObject")
 fs.CopyFile oldPath, newPath & "\" & strFile
 Set fs = Nothing
    Me.txt_Picture1.Visible = True
      Me.txt_Picture1.SetFocus
      Me.txt_Picture1.Text = strFile
      Me!Picture1.Picture = newPath & "\" & strFile
      Screen.PreviousControl.SetFocus
       Me.txt_Picture1.Visible = False
      
     Else
        
     End If
     
End Sub

Open in new window

0
Comment
Question by:gogetsome
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39675665
Dim strFile As String
strFile = Right(strPath, Len(strPath) - InStrRev(strPath, "\"))
strFile=Left(strfile, instr(strFile,".")-1) & "1" & mid(strfile,Instr(strfile,"."))

or you can use date as the number for the file

Dim strFile As String, strDate as string
strDate=Format(Now(),"yyyymmdd")
strFile = Right(strPath, Len(strPath) - InStrRev(strPath, "\"))
strFile=Left(strfile, instr(strFile,".")-1) & "_" & strDate & mid(strfile,Instr(strfile,"."))
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question