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

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

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.

Thanks,
Rufus

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

Samples available in the links,

http://support.microsoft.com/kb/213816

http://www.exceluser.com/explore/questions/vba_textcols.htm

Thanks,

http://codecollege.blogspot.com/


 

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
    targetBook.Activate
    TargetCell.PasteSpecial Paste:=xlValues
    SourceBook.Close False
End Sub