Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change filename before saving image

Posted on 2013-11-25
1
Medium Priority
?
252 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

722 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