Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-06-2023, 10:58 AM
gmaxey gmaxey is offline Macro to find a keyword and replace it by inserting the content of another Word document Windows 10 Macro to find a keyword and replace it by inserting the content of another Word document Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Something like this. Assumes your service portfolio document is in the same folder as your collection of description files and your description files are of the .docx format.


Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Dim strPath As String
Dim strKeyWord As String
  Set oRng = ActiveDocument.Range
  strKeyWord = "Orange"
  With oRng.Find
    .Text = "Orange"
    If .Execute Then
      oRng.Text = vbNullString
      strPath = ThisDocument.path & "\"
      oRng.InsertFile strPath & strKeyWord & ".docx"
    End If
  End With
lbl_Exit:
  Exit Sub
  Resume
End Sub

That said, a better idea might just be to create building blocks in a global template addin and use the building blocks to define product descriptions.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find a keyword and replace it by inserting the content of another Word document Find and Replace whole folder content - Word files Leslie Word VBA 7 03-01-2020 08:58 PM
Find and Replace Numbers Macro VBA in Microsoft Word Yotem189 Word VBA 3 09-20-2018 05:55 AM
Macro to find a keyword and replace it by inserting the content of another Word document Finding the graphics and inserting the keyword Ajay2506 Word VBA 4 06-28-2016 05:34 AM
Macro to find a keyword and replace it by inserting the content of another Word document Need Macro for Find and Replace, Inserting logo in Ms-Word. Aswinraj Word VBA 1 06-05-2016 04:33 PM
Macro to find a keyword and replace it by inserting the content of another Word document Word VBA Macro to Find and Replace based on the Alt Text of an Image bennymc Word VBA 1 01-27-2014 04:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft