Finding a file and displaying message

Loughsie

Board Regular
Joined
Dec 18, 2006
Messages
152
I need to edit a macro that opens a file that is as .csv

what i want is if the user incorrectly places a file in folder F:\report as .rep

then i want the user to see a message that advises them of the correct format and re run

file name is opened

start of macro is Workbooks.OpenText Filename:= _
"F:\Opened.csv",

if the user put a file name opened.rep i want them to see a message

ive been messing around with a few IF statement but can seem to get it right

anyone any ideas please
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
may seem too basic

couldn't you just put a on error resume next above the open code

or on error goto message


then have a message saying:
message:
Msgbox "Couldn't find Opend.Csv, please make sure it was correctly saved in the right format"
 
Upvote 0
Code:
on error goto message
Workbooks.OpenText Filename:= _ 
"F:\Opened.csv", 


goto theend
message:
msgbox "couldnt find file etc"
theend:
end sub
 
Upvote 0
ok yeah sort of what i was thinking of just i wasnt getting code rite ..thanks ill give it a go :)
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,285
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top