Results 1 to 2 of 2

Thread: VBA/Notepad - Please Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    1

    VBA/Notepad - Please Help

    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!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VBA/Notepad - Please Help

    Welcome to the Forums.

    You can open an Excel workbook by using code like so...

    VB Code:
    1. Option Explicit
    2. 'Add a reference to ms excel xx.0 object library
    3. Private moApp as excel.application
    4.  
    5. private sub form_load()
    6.     set moapp = new excel.application
    7. end sub
    8.  
    9. private sub command1_click()
    10.     dim oWB as excel.workbook
    11.     set owb = moapp.workbooks.open("C:\Test.xls")
    12.     if owb.sheets(1).cells(1, 1).value = strFirstMatchVar then ' assuming that this is your read in textfile value: strFirstMatchVar
    13.         'do nothing since found
    14.     else
    15.         msgbox "not found"
    16.     endif
    17.     owb.close true
    18.     set owb = nothing
    19.  
    20. end sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width