1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

WMI Script + Excel Macro, Find replace

Discussion in 'Business Applications' started by Timothyt, Sep 19, 2004.

Thread Status:
Not open for further replies.
  1. Timothyt

    Timothyt Thread Starter

    Joined:
    Sep 19, 2004
    Messages:
    2
    Hello,
    Im sorry if i placed this in the wrong thread, but i thought since it has to do with excel, this is the correct one.
    Iam trying to write a script to get rid of the "\\" in a excel file i output the netview to.

    Ive tried to inserting a macro for a find and replace, with no such luck.
    i was wondering what iam missing. Im sure its possible if such a macro can be recorded.

    Below is the code im using, ive looked everywhere for a solution, and googled for every string i thought i could get a solution from, with no luck :(

    Below is the last one ive tired, selecting the range from A1 - A100 and search only with in this range, no luck either :(


    Thanks in advance!

    Tim
    [email protected]


    dim objXLapp, objXLsheet
    dim strtemp
    dim nicset
    Set objShell = CreateObject("WScript.Shell")


    objShell.run ("%COMSPEC% /k net view| findstr \\ > netview_output.xls")


    ' Excel Application
    set objXLapp = createobject("excel.application")
    objXLapp.visible = true
    set objXLsheet = objXLapp.workbooks.open("c:\scripts2\netview_output.xls")
    objXLsheet.Range("A1:A100").Select _
    Selection.Replace What:="\", Replacement:="""", LookAt:= xlPart, _
    SearchOrder = xlByRows, MatchCase = False



    'Saves
    ChDir "C:\Scripts2"
    ActiveWorkbook.SaveAs Filename = "C:\Scripts2\netview_output.xls", FileFormat _
    = xlText, CreateBackup = False

    objXLapp.quit
    set objXLapp = Nothing
     
  2. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    What application are you trying to run this code from? Are you trying to run this code directly in Excel or another application?



    Rollin
     
  3. Timothyt

    Timothyt Thread Starter

    Joined:
    Sep 19, 2004
    Messages:
    2

    The extenstion for the script is .vbs
    i wrote the script for WMI
    It comes stock with windows XP and above.


    Tim
     
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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/275703

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice