Consulting

Results 1 to 2 of 2

Thread: Open a Word doc from ppt and update the doc...

  1. #1
    VBAX Newbie
    Joined
    Oct 2007
    Posts
    5
    Location

    Open a Word doc from ppt and update the doc...

    need a macro to open a word doc and update it based on textboxes on a ppt slide ... then save the doc.....


    anybody...help

  2. #2
    VBAX Newbie
    Joined
    Oct 2007
    Posts
    5
    Location

    ok, solved my own prob

    Sub OpenWordDoc()
    'In order to use this code you must set a reference to the
    'Word object library by doing this. In the VB Editor click
    'Tools, References. Then search for Microsoft Word n.n Object Library
    'where n.n will depend on your version of Word.
    Dim wdApp As Word.Application, wdDoc As Word.Document
    On Error Resume Next
    Set wdApp = GetObject(, "Word.Application")
    If Err.Number <> 0 Then 'Word isn't already running
        Set wdApp = CreateObject("Word.Application")
    End If
    On Error GoTo 0
    Set wdDoc = wdApp.Documents.Open("C:\doc.doc")
    wdApp.Visible = True
    'You can now do whatever you like with the Word document e.g.
    'wdDoc.PrintOut
     Dim rngStory As Range
      For Each rngStory In ActiveDocument.StoryRanges
        With rngStory.Find
            .Text = "COURSETITLE"
            .Replacement.Text = Slide115.CourseTitle
            .MatchCase = True
            .MatchWholeWord = True
            .Wrap = wdFindContinue
            .Execute Replace:=wdReplaceAll
        End With
      Next rngStory
    wdDoc.SaveAs "C:\doc.doc"
    wdDoc.Activate
    End Sub
    Last edited by Aussiebear; 04-28-2023 at 02:34 AM. Reason: Adjusted the code tags

Posting Permissions

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