need a macro to open a word doc and update it based on textboxes on a ppt slide ... then save the doc.....
anybody...help
need a macro to open a word doc and update it based on textboxes on a ppt slide ... then save the doc.....
anybody...help
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