473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Recent File

Hi All,

I have written the following code to open the most recent file in a
directory.

It seems to be getting stuck on Set xlApp = Excel.Application

It says the variable is undefined.

Any help would be really appreciated.

Ta

Andi
Option Explicit

'Finds the most recent file in a directory

'Sub Most_Recent_File()

Dim fs, f, f1, f2

'Dim vDT As Date

Dim fldr

'Dim vFName As String

Dim vDT, vFName

Dim Val_RECENT, Val_Open

Dim xlApp

fldr = "S:\SmartMarket\SMV Project Administration\Active Logs\Project Log\"

'fldr = File_Val

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.getfolder(fldr)

Set f1 = f.Files

For Each f2 In f1

If f2.DateLastModified > vDT Then

vFName = f2.Name

vDT = f2.DateLastModified

End If

Next

'Debug.Print vFName, vDT

'If IsMissing(Date_Val) Then

Val_Recent = vFName

'Else

'Val_RECENT = vDT

'End If

'End Sub

Val_Open = fldr & Val_Recent

MsgBox (Val_Open)

'Application.Excel.Workbooks.Open Val_Open

'Set xlApp = New Excel.Application

Set xlApp = Excel.Application

xlApp.Workbooks.Open(Val_Open)
Nov 21 '05 #1
1 1492
Hi,

You dont need the set in vb.net

xlApp = Excel.Application

Ken
-------------------------
"Andibevan" <an*******@remove-to-prevent-spam-hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have written the following code to open the most recent file in a
directory.

It seems to be getting stuck on Set xlApp = Excel.Application

It says the variable is undefined.

Any help would be really appreciated.

Ta

Andi
Option Explicit

'Finds the most recent file in a directory

'Sub Most_Recent_File()

Dim fs, f, f1, f2

'Dim vDT As Date

Dim fldr

'Dim vFName As String

Dim vDT, vFName

Dim Val_RECENT, Val_Open

Dim xlApp

fldr = "S:\SmartMarket\SMV Project Administration\Active Logs\Project Log\"

'fldr = File_Val

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.getfolder(fldr)

Set f1 = f.Files

For Each f2 In f1

If f2.DateLastModified > vDT Then

vFName = f2.Name

vDT = f2.DateLastModified

End If

Next

'Debug.Print vFName, vDT

'If IsMissing(Date_Val) Then

Val_Recent = vFName

'Else

'Val_RECENT = vDT

'End If

'End Sub

Val_Open = fldr & Val_Recent

MsgBox (Val_Open)

'Application.Excel.Workbooks.Open Val_Open

'Set xlApp = New Excel.Application

Set xlApp = Excel.Application

xlApp.Workbooks.Open(Val_Open)

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Nova's Taylor | last post by:
Hi folks, I am a newbie to Python and am hoping that someone can get me started on a log parser that I am trying to write. The log is an ASCII file that contains a process identifier (PID),...
3
by: Suresh Kumaran | last post by:
How do you program in VB.NET to show the most recent used document in a dropdown menu? I am referring to something like in MS WORD or EXCEL where it shows the recent document the user was working...
3
by: Larry Bates | last post by:
I recently upgraded from 2.2 to 2.4 (ActiveState for Windows). I was accustomed to having the most recent 10 files that I had edited show up under File menu under Recent. After upgrading these...
1
by: Eric Robishaw | last post by:
In VS.net 2003, my recent files list will not update the Date. If I open a project from the list, modify it and close... the next time I load VS.net, the project shows the same old date. It...
7
by: William Payne | last post by:
Hello, have you seen a recent files menu in a GUI application? In many GUI applications there's a menu the displays the most recent files that has been opened by the program. Say such a menu has...
2
by: satyaprakash47 | last post by:
Hello How can we remove a specific file from the window recent file list through vb.Net.
4
by: Lee | last post by:
I have an application where I need to find the most recent file placed in a folder. For example, my users periodically place an image file with the format "ImageXXXX.jpg" (where XXXX is some...
2
by: C# programmer | last post by:
Hi All, I'm working on a project which requires tracking of recent document downloads. There is a feature in which user can download the docs without logining into the website for some of the...
4
by: zacks | last post by:
Most applications whose purpose is to work with various types of files implement a "Most Recent Files" list, where the last, say, four files accessed by the application can quickly be re-opened by...
7
by: PawelSokolowski | last post by:
Hi all, I migrated to VS2008, and I cannot find a way to get Recent Projects in File menu. I tried to customize the menu, but no success. Any ideas ? Regards Pawel
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.