+ Reply to Thread
Results 1 to 2 of 2

Macro to open word doc, then open another file in word and then excute a find replace

  1. #1
    Registered User
    Join Date
    07-21-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    2

    Macro to open word doc, then open another file in word and then excute a find replace

    Office 2003

    I've got a file thats created in excell which is to be loaded to a mainframe as a text file (tab delimited), but due to how excel sees the data it put speech marks in the file, i've created a macro within a word document to open the text file and remove them.

    I've done some googling and I know that you can set an macro in excel to open a word doc and excute a macro from within it or have excel open a word document and manipulate it from within the excel macro.

    Anyhow i've got as far as below but i keep getting debug errors on the lines in red. can anyone help

    Sub manip()
    Dim wdApp As Word.Application
    Set wdApp = New Word.Application
    wdApp.Visible = True
    wdApp.Documents.Open Filename:="P:\IBM Calendar.doc"
    With wdDoc
    ChangeFileOpenDirectory "P:\"
    Documents.Open Filename:="calpot.txt", ConfirmConversions:=False, AddToRecentFiles:=False, Format:=wdOpenFormatAuto
    Windows("calpot").Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    With Selection.Find
    .Text = """"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End With
    ActiveDocument.save
    ActiveWindow.Close
    Set wdApp = Nothing
    End Sub

  2. #2
    Registered User
    Join Date
    07-21-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro to open word doc, then open another file in word and then excute a find rep

    can anyone 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