Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 12-12-2012, 10:27 AM
dmarie123 dmarie123 is offline Replace text with Quick Part using VBA Windows 7 64bit Replace text with Quick Part using VBA Office 2007
Novice
Replace text with Quick Part using VBA
 
Join Date: Dec 2012
Location: New Yuk
Posts: 23
dmarie123 is on a distinguished road
Default

I do like the deep end...hahaha! Thank you Greg for your help with this!!

I have a few questions (big shocker, I know )

1. The macro works for but it's only changing the first instance of "This student". When I first ran it it worked for every instance...
I get a Run-time error 4198? When I debug the following line is highlighted:
Set oCC = ActiveDocument.ContentControls.Add(wdContentContro lText, oRng)

I have other document properties in the word doc, I'm not sure if that's problematic, I wouldn't think so but see previous post about "in over my head"?

2. Can I add more parameters? Like this:
strFind() = Split("This student|student|STUDENT|this Student|This Student", "|") and then change the MatchCase to True?

3. I'm wondering if there is a Not statement I can tie in? In SQL you can basically say look for "student" but not "my student" and then when you find the correct one replace it with "Ann Smith". Is selective replacing possible w/ VBA? The word "student" appears in areas of general text and should not be changed to the proper name (that is now tied to the content control). Also, the word "students" appears randomly and I don't want that to change. I tried changing it from False to True for .MatchWholeWord but then it didn't recognize both terms...It's not specific areas or I would be asking for help with ranges haha.

Thank you in advance (again) for your help. I'm trying to figure these things out before I post. So far I just have a headache .

Last edited by dmarie123; 12-12-2012 at 12:03 PM.
Reply With Quote
 

Tags
content control, vba in microsoft word, word 2007



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace text with Quick Part using VBA Macro to find text and replace with form field containing that text iiiiifffff Word VBA 16 06-04-2016 01:47 AM
How to Rename a Quick Part sleake Word 14 10-14-2013 09:21 AM
quick replace, sort, change columns userman Excel 1 05-01-2012 06:24 AM
Quick change for all text boxes in a presentation tmlander PowerPoint 1 03-09-2012 01:20 AM
Date display in Mod quick part header Jrul John Word 1 08-02-2010 12:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:34 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