473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking file existance

2 New Member
how do I check if a file with a specific name exists in a folder on my computer. Im working on a macro in MSWord. Please help.

Some suggested:

Expand|Select|Wrap|Line Numbers
  1. If System.IO.File.Exists(fileToOpen) = True Then
  2. ...
  3.  
  4. Else
  5.  
  6. ...
  7.  
  8. EndIf
Jun 19 '07 #1
3 1013
borec
2 New Member
I found

Object.FileExist(FileToOpen) but I can't get it work. Debbuger alerts error.
Jun 19 '07 #2
Killer42
8,435 Recognized Expert Expert
Some suggested:
Expand|Select|Wrap|Line Numbers
  1. If System.IO.File.Exists(fileToOpen) = True Then
  2.   ...
  3. Else
  4.   ...
  5. EndIf
Well, does it work?

As for your other post, please give us the specific details of the reported error.

Also, I don't know whether it matters (not really my area of expertise) but what version of Word is this?
Jun 19 '07 #3
Killer42
8,435 Recognized Expert Expert
Just a quick note - the Dir() function is useful for checking whether files exist.

For example...
Expand|Select|Wrap|Line Numbers
  1. If Dir(fileToOpen) = "" Then
  2.   ' File doesn't exist
  3. End If
Check the doco for parameters.
Jun 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2036
by: Cherrish Vaidiyan | last post by:
hello scholars, i am just learning PHP. i have a small requirement in urgency.i want to create a functionality of archiving in which a user can upload any file through a browser to a location....
2
1392
by: William Kossack | last post by:
I'm trying to write a program in cold fusion to check the existance of fields and data types according to requirements I was looking at the syscolumns table for some of this information but I've...
4
1386
by: Lambuz | last post by:
Is there any way to check the existance of a window by the name ? I'm using this code: window.open("http://www.google.com",'targetWin1') If I open a window using previous code without getting...
7
1843
by: Ajit | last post by:
Is there anyway to check for existance of a file on different machine. i.e. we have a data file (text file) thats stored on some other machine as its not to be exposed in case the web server is...
5
5773
by: A.M | last post by:
Hi, To check if QueryString contains a key I compaire it with null like this code: if (Request.QueryString!=null) { Label1.Text= Request.QueryString; } else
6
3656
by: Juggler | last post by:
Hi all I've written a program in VB.NET that allows the user to build quotes for installing shower enclosures. As part of the program, I've included a blank Access database. I've provided them...
6
1117
by: Jm | last post by:
Hi all Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL and it wasnt available i could use the on error resume next to get past the code that calls it and trap it...
6
5242
by: PengYu.UT | last post by:
The following code open the file "example.txt" in the current directory. int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close();...
6
1349
by: Andy B | last post by:
How do you check to see if a certain folder exists? I also need to know how to check for the existance of a certain sql server database table.
0
7074
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...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.