![]() |
#1
|
|||
|
|||
![]()
I have several different ads but all have the same text. I am wanting a macro that will allow me to find a phone number or a date, etc. and change it in all of the open documents.
I have searched the forums and found a few bits of code. I don't know the code well enough to modify it to my needs. I tried recording a macro by doing a Find/Replace Text but it doesn't recognize those dialogs. I'm using CorelDraw 11.633 Thanks for any help. Jim |
#2
|
||||
|
||||
![]()
Wow, CorelDRAW 11, I don't have that on any machine, so I can't test this under 11 for you. But this works in X4. Hopefully it gives you a start.
Code:
Sub ReplaceTextAcrossOpenDocs() Const txtFIND As String = "Blue" 'The word you want to find and replace Const txtREPLACE As String = "Yellow" 'The new word to replace the old Dim d As Document Dim p As Page Dim s As Shape For Each d In Documents 'Loop all the open documents For Each p In d.Pages 'Loop each page For Each s In p.Shapes 'Loop each shape If s.Type = cdrTextShape Then 'If the shape is text do the replace s.Text.Story = Replace(s.Text.Story.Text, txtFIND, txtREPLACE) End If Next s Next p Next d End Sub -Shelby |
#3
|
||||
|
||||
![]()
Even Better try this:
Code:
Sub ReplaceTextAcrossOpenDocs() Const txtFIND As String = "Yellow" 'The word you want to find and replace Const txtREPLACE As String = "Blue" 'The new word to replace the old Dim d As Document Dim p As Page For Each d In Documents 'Loop all the open documents For Each p In d.Pages 'Loop each page p.TextReplace txtFIND, txtREPLACE, True, False Next p Next d End Sub -Shelby |
#4
|
|||
|
|||
![]()
That is just insane how quick that works. You make it look so easy. The code is so hard to undersand. It's like greek. I've tried to figure these things out from other code and try to modify it to fit my needs but I'm just not grasping it.
Thanks very much for this last code. The first one didn't work for me but the second one did. Is there a way to prompt me to enter the text to replace or do I just need to change the text to replace in the macro? |
#5
|
||||
|
||||
![]()
The easy way is to have two input boxes. If you want it to look nice and only have a single dialog you would need to create and design a form.
Code:
Sub ReplaceTextAcrossOpenDocs() Dim txtFIND As String 'The word you want to find and replace Dim txtREPLACE As String 'The new word to replace the old Dim d As Document Dim p As Page Dim s As Shape txtFIND = InputBox("Enter the string you wish to replace:", "Replace Text Across OpenDocs") txtREPLACE = InputBox("Enter the new string:", "Replace Text Across OpenDocs") For Each d In Documents 'Loop all the open documents For Each p In d.Pages 'Loop each page p.TextReplace txtFIND, txtREPLACE, True, False Next p Next d End Sub -Shelby |
#6
|
|||
|
|||
![]()
Oh my gosh that is the coolest thing I've seen in a while!!!
That is just awesome. I'm smiling as I'm typing and I laughed out loud when I tried it. Thank you so much!! I'll get your "check" in the mail and I'll throw in a batch of chocolate chip cookies too!! ![]() Thank so much!! ![]() ![]() |
#7
|
|||
|
|||
![]()
This script almost helps me, I am trying to find a solution almost similar to the script in this thread with following changes -
1. have two folder browsing fields like File converter.gms for choosing source folder and destination folder 2. the input text field, and the output-replace text field 3. And the scripts runs through the entire folder, opens the files in hidden or full mode, saves and close with same name. |
![]() |
Tags |
find, macros, replace, text |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
FInd index of shapes grouped with text | rubidoux | CorelDRAW/Corel DESIGNER VBA | 3 | 07-10-2007 22:00 |
Find all text and apply text style | keytecstaff | CorelDRAW/Corel DESIGNER VBA | 2 | 18-05-2006 09:48 |
Find and Replace Text with Form | RVogel | CorelDRAW/Corel DESIGNER VBA | 1 | 24-03-2005 09:37 |
Rotating multiple artistic text objects | geopig | CorelDRAW/Corel DESIGNER VBA | 6 | 01-03-2005 16:51 |
Find/Replace with CorelDraw 9 and VB 6 | sfldan | CorelDRAW/Corel DESIGNER VBA | 1 | 10-07-2003 17:44 |