Solved

Change filename before saving image

Posted on 2013-11-25
1
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 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

Industry Leaders: 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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 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