Problem with Merge Centre VBA Codes?

Asked By 10 points N/A Posted on -
qa-featured

Good Day Experts!

I need your help in creating my Merge Centre VBA program. Can you share the sample codes of your program? I need to create a short, simple but efficient Merge Centre program using VB 6.0 or VB .Net. If you're a Visual Basic expert then I need your expertise. Please share some of your knowledge.

Thank you so much,

Alison

SHARE
Answered By 0 points N/A #152701

Problem with Merge Centre VBA Codes?

qa-featured

 

Hello Alison,
 
There is a lot that you can do when it comes to merging cells in VBA program. Well, I will show you a sample merging program in VB 6.0.
 
I created a file merge program where the user gives location of 2 text files. This code will be able to create a single merged file in a folder from where the application is running.
 

 

Sub MergeFiles()
Dim Txt As String, File1 As String, File2 As String, WriteFile As String
File3 = Trim(txt_SourceFile3)
File4 = Trim(txt_SourceFile4)
WriteFile = App.Path & "Merged_File.txt"
 
On Error GoTo ErrHandler
Open File3 For Input As #3
Open WriteFile For Output As #4
 
Do Until EOF(1)
    Line Input #3, Txt
    Txt = Trim(Txt)
    Print #4, Txt
Loop
Close #3
 
Open File2 For Input As #3
Do Until EOF(1)
    Line Input #3, Txt
    Txt = Trim(Txt)
    Print #4, Txt
Loop
Close #3
 
Close #4
MsgBox "Merged File Created: " & vbCr & WriteFile, vbInformation
 
Exit Sub
ErrHandler:
MsgBox Err.Description, vbCritical
Reset
Err.Clear
End Sub

 

I hope this gives you some sort of an idea on your ongoing Merge Centre.
Best of luck!

 

Login/Register to Answer

Related Questions