Click here to Skip to main content
15,891,473 members
Home / Discussions / Visual Basic
   

Visual Basic

 
JokeRe: Please help me, this program does not work. Pin
Mycroft Holmes6-Apr-13 23:31
professionalMycroft Holmes6-Apr-13 23:31 
GeneralRe: Please help me, this program does not work. Pin
Eddy Vluggen7-Apr-13 6:51
professionalEddy Vluggen7-Apr-13 6:51 
QuestionArgumentOutOfRangeException Pin
IgaBaro4-Apr-13 17:51
IgaBaro4-Apr-13 17:51 
AnswerRe: ArgumentOutOfRangeException Pin
David C# Hobbyist.5-Apr-13 5:55
professionalDavid C# Hobbyist.5-Apr-13 5:55 
Questionsearch a excel document Pin
staticstate2-Apr-13 7:00
staticstate2-Apr-13 7:00 
AnswerRe: search a excel document Pin
Kenneth Haugland2-Apr-13 9:13
mvaKenneth Haugland2-Apr-13 9:13 
GeneralRe: search a excel document Pin
Maciej Los10-Apr-13 3:38
mveMaciej Los10-Apr-13 3:38 
AnswerRe: search a excel document Pin
Maciej Los10-Apr-13 5:10
mveMaciej Los10-Apr-13 5:10 
VBA for Excel. Data stored in Sheet1, columns: A - CODE, B - NAME. Searches for files in the same folder in which is stored workbook.

VB
Option Explicit

Sub ChangeTheNamesOfFiles()
Dim wsh As Worksheet
Dim sInitialPath As String, sOldName As String, sNewName As String, sExt As String
Dim i As Integer

sInitialPath = ThisWorkbook.Path & "\"
sExt = ".txt"
Set wsh = ThisWorkbook.Worksheets(1)
i = 2
Do While wsh.Range("A" & i)
    sOldName = wsh.Range("A" & i)
    sOldName = FindFile(sInitialPath, sOldName, sExt)
    sNewName = sInitialPath & wsh.Range("B" & i) & sExt
    If sOldName <> "" Then
        FileCopy sOldName, sNewName
        Kill sOldName
    End If

Loop


End Sub


Function FindFile(ByVal sDir As String, ByVal sFileName As String, Optional ByVal sFileExt As String = ".txt") As String
Dim retVal As String

If Right(sDir, 1) <> "\" Then sDir = sDir & "\"
retVal = Dir(sDir & sFileName & sFileExt, vbNormal)

FindFile = retVal

End Function

Maciej Los

QuestionSearching Data Pin
Ahmad Rifai Yusuf2-Apr-13 3:45
Ahmad Rifai Yusuf2-Apr-13 3:45 
AnswerRe: Searching Data Pin
Kenneth Haugland2-Apr-13 9:15
mvaKenneth Haugland2-Apr-13 9:15 
GeneralRe: Searching Data Pin
Ahmad Rifai Yusuf3-Apr-13 13:01
Ahmad Rifai Yusuf3-Apr-13 13:01 
QuestionHello All, need help to SET 5 days in a weeks in VB 2010 EXPRESS Pin
Yazid Aura Robbani1-Apr-13 22:08
professionalYazid Aura Robbani1-Apr-13 22:08 
AnswerRe: Hello All, need help to SET 5 days in a weeks in VB 2010 EXPRESS Pin
Bernhard Hiller1-Apr-13 22:47
Bernhard Hiller1-Apr-13 22:47 
GeneralRe: Hello All, need help to SET 5 days in a weeks in VB 2010 EXPRESS Pin
Yazid Aura Robbani2-Apr-13 8:53
professionalYazid Aura Robbani2-Apr-13 8:53 
GeneralRe: Hello All, need help to SET 5 days in a weeks in VB 2010 EXPRESS Pin
Maciej Los10-Apr-13 3:33
mveMaciej Los10-Apr-13 3:33 
GeneralRe: Hello All, need help to SET 5 days in a weeks in VB 2010 EXPRESS Pin
Yazid Aura Robbani10-Apr-13 11:16
professionalYazid Aura Robbani10-Apr-13 11:16 
Question[SOLVED] Word 2010 VBA - reading classical wordarts Pin
Bart Van Eyndhoven1-Apr-13 21:58
Bart Van Eyndhoven1-Apr-13 21:58 
AnswerRe: Word 2010 VBA - reading classical wordarts Pin
Kenneth Haugland2-Apr-13 9:19
mvaKenneth Haugland2-Apr-13 9:19 
GeneralRe: Word 2010 VBA - reading classical wordarts Pin
Bart Van Eyndhoven2-Apr-13 21:25
Bart Van Eyndhoven2-Apr-13 21:25 
GeneralRe: Word 2010 VBA - reading classical wordarts Pin
Bart Van Eyndhoven7-Apr-13 21:52
Bart Van Eyndhoven7-Apr-13 21:52 
AnswerRe: Word 2010 VBA - reading classical wordarts Pin
Kenneth Haugland7-Apr-13 23:02
mvaKenneth Haugland7-Apr-13 23:02 
GeneralRe: Word 2010 VBA - reading classical wordarts Pin
Bart Van Eyndhoven8-Apr-13 22:19
Bart Van Eyndhoven8-Apr-13 22:19 
QuestionMybase.New problem Pin
Christoffer Svensson31-Mar-13 6:42
Christoffer Svensson31-Mar-13 6:42 
AnswerRe: Mybase.New problem Pin
Dave Kreskowiak31-Mar-13 7:11
mveDave Kreskowiak31-Mar-13 7:11 
QuestionEditable Grid for Windows 7 (32 or 64 bit) Pin
h0k3n931-Mar-13 6:12
h0k3n931-Mar-13 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.