+ Reply to Thread
Results 1 to 5 of 5

Word dialog editreplace

  1. #1
    Shawn G.
    Guest

    Word dialog editreplace

    The following code opens a word document to be edited. The WordDialog is to
    find and replace the text without user interaction. How do I get the Word
    Dialog to do this???? WordDialog.execute doesn't work. Any ideas?????


    Set WordApp = CreateObject("word.application") 'open Word session
    WordApp.Visible = True 'Word visible during operation
    WordApp.Activate
    Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc
    Set WordDialog = WordApp.Dialogs(wdDialogEditReplace)
    With WordDialog
    .Find = "<RIA name>"
    .Replace = "TESTING!!!"
    End With
    On Error Resume Next
    WordDialog.Execute
    On Error GoTo Err_WordDocs

    Thank You,

  2. #2
    Harald Staff
    Guest

    Re: Word dialog editreplace

    Hi

    Dialogs ARE for user interaction. Without user interaction don't use
    dialogs.

    Record a macro in Word as you do a manual find-replace, and you'll get
    pretty good code for automatic find-replace.

    HTH. Best wishes Harald

    "Shawn G." <[email protected]> skrev i melding
    news:[email protected]...
    > The following code opens a word document to be edited. The WordDialog is
    > to
    > find and replace the text without user interaction. How do I get the Word
    > Dialog to do this???? WordDialog.execute doesn't work. Any ideas?????
    >
    >
    > Set WordApp = CreateObject("word.application") 'open Word session
    > WordApp.Visible = True 'Word visible during operation
    > WordApp.Activate
    > Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc
    > Set WordDialog = WordApp.Dialogs(wdDialogEditReplace)
    > With WordDialog
    > .Find = "<RIA name>"
    > .Replace = "TESTING!!!"
    > End With
    > On Error Resume Next
    > WordDialog.Execute
    > On Error GoTo Err_WordDocs
    >
    > Thank You,




  3. #3
    Shawn G.
    Guest

    Re: Word dialog editreplace

    Any idea how to convert this to a find and replace without interaction?

    "Harald Staff" wrote:

    > Hi
    >
    > Dialogs ARE for user interaction. Without user interaction don't use
    > dialogs.
    >
    > Record a macro in Word as you do a manual find-replace, and you'll get
    > pretty good code for automatic find-replace.
    >
    > HTH. Best wishes Harald
    >
    > "Shawn G." <[email protected]> skrev i melding
    > news:[email protected]...
    > > The following code opens a word document to be edited. The WordDialog is
    > > to
    > > find and replace the text without user interaction. How do I get the Word
    > > Dialog to do this???? WordDialog.execute doesn't work. Any ideas?????
    > >
    > >
    > > Set WordApp = CreateObject("word.application") 'open Word session
    > > WordApp.Visible = True 'Word visible during operation
    > > WordApp.Activate
    > > Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc
    > > Set WordDialog = WordApp.Dialogs(wdDialogEditReplace)
    > > With WordDialog
    > > .Find = "<RIA name>"
    > > .Replace = "TESTING!!!"
    > > End With
    > > On Error Resume Next
    > > WordDialog.Execute
    > > On Error GoTo Err_WordDocs
    > >
    > > Thank You,

    >
    >
    >


  4. #4
    Shawn G.
    Guest

    Re: Word dialog editreplace

    Figured it out, Thanks for the Help!

    Set WordApp = CreateObject("word.application") 'open Word session
    WordApp.Visible = True 'Word visible during operation
    WordApp.Activate
    Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc

    With WordDoc.Content.Find
    .text = "<RIA name>"
    With .Replacement
    .text = "testing!!!"
    End With
    .Execute Replace:=wdReplaceAll
    End With

    On Error Resume Next

    On Error GoTo Err_WordDocs


    "Shawn G." wrote:

    > Any idea how to convert this to a find and replace without interaction?
    >
    > "Harald Staff" wrote:
    >
    > > Hi
    > >
    > > Dialogs ARE for user interaction. Without user interaction don't use
    > > dialogs.
    > >
    > > Record a macro in Word as you do a manual find-replace, and you'll get
    > > pretty good code for automatic find-replace.
    > >
    > > HTH. Best wishes Harald
    > >
    > > "Shawn G." <[email protected]> skrev i melding
    > > news:[email protected]...
    > > > The following code opens a word document to be edited. The WordDialog is
    > > > to
    > > > find and replace the text without user interaction. How do I get the Word
    > > > Dialog to do this???? WordDialog.execute doesn't work. Any ideas?????
    > > >
    > > >
    > > > Set WordApp = CreateObject("word.application") 'open Word session
    > > > WordApp.Visible = True 'Word visible during operation
    > > > WordApp.Activate
    > > > Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc
    > > > Set WordDialog = WordApp.Dialogs(wdDialogEditReplace)
    > > > With WordDialog
    > > > .Find = "<RIA name>"
    > > > .Replace = "TESTING!!!"
    > > > End With
    > > > On Error Resume Next
    > > > WordDialog.Execute
    > > > On Error GoTo Err_WordDocs
    > > >
    > > > Thank You,

    > >
    > >
    > >


  5. #5
    Harald Staff
    Guest

    Re: Word dialog editreplace

    That was fast. Good job, thanks for the feedback.

    Best wishes Harald

    "Shawn G." <[email protected]> skrev i melding
    news:[email protected]...
    > Figured it out, Thanks for the Help!




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1