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


renaming files using vb code

Posted on 2001-06-06
Medium Priority
Last Modified: 2010-05-02
Dim strOldFilename as string
Dim strNewFileName as string

'now just say strNewFileName = P1S1P1

'the original filename is image1.jpj
'this file is stored in C:\database\images\
we want image.jpj to change to p1s1p1.jpg now how would I go about this using vb code. I have used a common dialog box used to select the file. eg image1.jpg.

The location of the filename can be stored in a variable.
Dim strFileName As String

With frmAssessment.dlgImage
    .FileName = ""
End With

strFileName = frmAssessment.dlgImage.FileName

Now how can I change the name of the file. Any other ideas.
Question by:Yakeni
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
  • 2
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6162621
NAME strOldFileName AS strNewFileName


Expert Comment

ID: 6162622
Public Sub RenameFile(ByVal strFilename As String, _
  ByVal strNewFilename As String)
  On Error GoTo PROC_ERR
  Name strFilename As strNewFilename
  Exit Sub
  MsgBox "Error: " & Err.Number & vbCrLf & _
         "Description: " & Err.Description, vbCritical
  Resume PROC_EXIT
End Sub

Accepted Solution

sharmon earned 200 total points
ID: 6162623
just can seem to hit the button fast enough:)

Author Comment

ID: 6162647
That was simple wasnt it

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

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