check for presence of text file

M

meg99

using 2003. I have a template MPP that I use to open an MPX file,
import tab delimited text via a map and then save as an MPP.

I have Rod Gill's book that shows how to import Excel, Access, and SQL
data but nothing on importing text tiles.

Problem. - I need to check for the presence of the text file. I can't
seem to find the right command -

psuedo code:

open mpp template
check for text file (preferably a dialog box for user selection)
if found
import with predefined import map
else
alert user
endif


myfile = FileOpen()
produces a dialog that defaults to mpp files
myfile = FileOpen("*.txt")
produces an error


How can I get a dialog that shows the text files?


meg99
 
J

John

meg99 said:
using 2003. I have a template MPP that I use to open an MPX file,
import tab delimited text via a map and then save as an MPP.

I have Rod Gill's book that shows how to import Excel, Access, and SQL
data but nothing on importing text tiles.

Problem. - I need to check for the presence of the text file. I can't
seem to find the right command -

psuedo code:

open mpp template
check for text file (preferably a dialog box for user selection)
if found
import with predefined import map
else
alert user
endif


myfile = FileOpen()
produces a dialog that defaults to mpp files
myfile = FileOpen("*.txt")
produces an error


How can I get a dialog that shows the text files?


meg99

meg99,
I don't know if this will help but do you perhaps have your control
panel folder options set to suppress hide extensions of known file
types? If so, the .txt may not be visible.

John
Project MVP
 
M

meg99

meg99,
I don't know if this will help but do you perhaps have your control
panel folder options set to suppress hide extensions of known file
types? If so, the .txt may not be visible.

John
Project MVP- Hide quoted text -

- Show quoted text -

The conrol panel folder is set to SHOW extensions

Glen
 
M

meg99

Hi,

There is sample code for displaying a file open dialog for the user to
browse for a file (module 25). If you have a path in a variable, then you
can test that a file exists with:

If Dir(MyFilePath)="" then
'File does not exist
end if

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx

---------------------------------------------------------------------------­-------------------------













- Show quoted text -

Rod,
Thanks. Just what I need. I guess I skipped over module 25. In any
case, after using FileOpen in Project and GetOpenFilename in Excel, it
didn't occur to me that I needed a Windows API call. Thanks agan!

Glen
 
R

Rod Gill

Unfortunately Project doesn't follow all of Excel's VBA features! Windows
API code is not pretty, but there are plenty of working examples (including
on msdn.microsoft.com) so you just have to copy and paste.

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx


----------------------------------------------------------------------------------------------------


Hi,

There is sample code for displaying a file open dialog for the user to
browse for a file (module 25). If you have a path in a variable, then you
can test that a file exists with:

If Dir(MyFilePath)="" then
'File does not exist
end if

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx

---------------------------------------------------------------------------­-------------------------













- Show quoted text -

Rod,
Thanks. Just what I need. I guess I skipped over module 25. In any
case, after using FileOpen in Project and GetOpenFilename in Excel, it
didn't occur to me that I needed a Windows API call. Thanks agan!

Glen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top