VB 6.0 - excel VBA - import latest modified *.log file

Asked By Rufus Rules on 28-Jun-09 12:41 PM

I am new to excel VB, i would like to import an *.log file directly to excel meaning i do not want to browse and select the file i want to have a macro which will directly import the *.log file direclty to the excel workbook

I tried with Application.Dialogs.show but not succesful please help.

also need to make sure that the imported file is the latest modified file in that particular folder

thanks in advance for your great assistance.


Samples - Sakshi a replied to Rufus Rules on 28-Jun-09 01:28 PM

Samples available in the links,






Harry L replied to Rufus Rules on 29-Jun-09 12:38 AM

hi you can try the following procudre

Sub ImportFile()

    Dim targetBook As Workbook
    Dim SourceBook As Workbook
    Dim TargetCell As Range
    Application.ScreenUpdating = False
    Set targetBook = ActiveWorkbook
    Set TargetCell = ActiveCell
    ReturnValue = Application.Dialogs(xlDialogOpen).Show("*.log")
    Dim ReturnValue As Boolean
        If ReturnValue = False Then Exit Sub
    Set SourceBook = ActiveWorkbook
    Range(Range("A1"), Range("A1").SpecialCells(xlLastCell)).Copy
    TargetCell.PasteSpecial Paste:=xlValues
    SourceBook.Close False
End Sub