PDA

Click to See Complete Forum and Search --> : VBA/Notepad - Please Help


cdeep
Jul 25th, 2005, 04:32 PM
Hello all,

I'm new to the forum and pretty new to programming too. I'm trying to work on a problem that is pretty difficult for me. Hope one of you guys can help me.

Here's what I'm trying to do - I have a list of words in an excel sheet. I'd like to open an existing text file and compare the list of words (in excel) with the words in the notepad file and prompt if there is a word that does not match with any word in the list. I know how to open a notepad file and other basic stuff. any help will be appreciated. Thanks!

P.S- I searched the forums. I could not find anything similar. Sorry if the issue has been addressed!

RobDog888
Jul 25th, 2005, 05:02 PM
Welcome to the Forums.

You can open an Excel workbook by using code like so...
Option Explicit
'Add a reference to ms excel xx.0 object library
Private moApp as excel.application

private sub form_load()
set moapp = new excel.application
end sub

private sub command1_click()
dim oWB as excel.workbook
set owb = moapp.workbooks.open("C:\Test.xls")
if owb.sheets(1).cells(1, 1).value = strFirstMatchVar then ' assuming that this is your read in textfile value: strFirstMatchVar
'do nothing since found
else
msgbox "not found"
endif
owb.close true
set owb = nothing

end sub