Excel VBA: Sub to find if URL exists

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

tulip123

Thread Starter
Joined
Apr 17, 2001
Messages
7
I need to find out whether a file which is actually a URL (i.e. it is located on a web-server) exists, from a VBA subroutine in Excel.
Any way to do that ?
 

Anne Troy

Anne
Joined
Feb 14, 1999
Messages
11,746
Your questions sound an awful lot like coursework. We don't want to answer your coursework questions for you. However, we hope you'll be honest about it and tell us if that's what you're doing. What we WILL do is give you a lot of guidance/direction in finding your answers.

Also, if you are doing VBA coursework, might I suggest you get thyself to the newsgroups? Let me know if you need help with those.

Here's some really terrific Excel resources:

http://www.cpearson.com/excel/topic.htm
http://www.erlandsendata.no/english/downloads/index.htm
http://www.turedata.se
http://www.ozgrid.com
http://msdn.microsoft.com/library/officedev/office97/web/fulltoc.htm

Good luck!
 

tulip123

Thread Starter
Joined
Apr 17, 2001
Messages
7
Hi Dreamboat,

This is not a coursework question, it's a real problem I encountered while working on an Excel VBA application.

I'll manage it some other way.

Thanks,
Tulip.
 
Joined
Dec 12, 2000
Messages
310
Those links gave me the answer to something I have been beating my head over for about a month now.

Kudos to Dreamboat......
 

Anne Troy

Anne
Joined
Feb 14, 1999
Messages
11,746
Have you tried the newsgroups?



:) Hey, ncz.
Very happy to hear it. Should'a just asked me.
 
Joined
Dec 12, 2000
Messages
310
I thought about it, but that takes all of the fun out of getting frustrated....lol...
 

tulip123

Thread Starter
Joined
Apr 17, 2001
Messages
7
No I didn't.

I found out that the Open method of a workbook in the following way:

On Error Resume Next
Set wb = Workbooks.Open(FileName:="xxx")

' Checking if the file exists.
If wb Is Nothing Then


Else

End If
 

tulip123

Thread Starter
Joined
Apr 17, 2001
Messages
7
No I didn't.

I found out that I can use the 'Open' method of a workbook in the following way:

On Error Resume Next
Set wb = Workbooks.Open(FileName:="xxx")

' Checking if the file exists.
If wb Is Nothing Then

' The file does not exist.
...

Else

' The file exists.
...

End If

and that the file name can be a URL. Of course, in this way the file will be opened in another Excel workbook, so if it's not needed later it should be closed (the files I want to check are always text files, so opening them in an Excel workbook will cause no problems).

I'm attaching the code so that if anybody else encounters this problem maybe this can help him/her (instead of sending them to newsgroups...)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top