Computing.Net > Forums > Programming > Redundant Field Codes [Off. '03 VBA

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Redundant Field Codes [Off. '03 VBA

Reply to Message Icon

Original Message
Name: 24HG_Hoop
Date: August 5, 2008 at 07:43:49 Pacific
Subject: Redundant Field Codes [Off. '03 VBA
OS: XP
CPU/Ram: AMD 3K, 2G
Manufacturer/Model: clone
Comment:

Hi all,

Forgive my semi-newbieness. I'm trying! I've come a long way, thanks in large part to you all and vbforums.com. I'm nearing in on the last leg of a major endeavour and have hit a little snag that maybe (hopefully) somebody can help out with. Thanks for taking the time to read me wall o' text below.


I've set up several hundred field codes, taking inputs from Excel and bringing them into a 100-page Word document. MANY of the field codes are redundant, and cause a lot of overhead - things such as "I" versus "We", "I was" versus "We were", etc. Approximately half of what's coming in to Word is duplicated, and an update of all fields takes 3-5 minutes.

I've tried creating a bookmark to the first instance of a redundant field, and just used an OLE link to reproduce the same field throughout Word. That works fine ... until I rename Word and Excel [e.g., when I start anew with another project]. In that instance, my Excel->Word field codes get renamed with the new path and new file name; however, Word's OLE links do not change. They stay static to the original file name - and I've not been able to make them programatically change (yet).

Let me preface this all by saying that I've got a macro that I fire from a Template.xls file. The macro looks in the template for the name of a document template in my template directory [i.e., BANK.dot, CHURCH.dot, etc.], opens the right template, then prompts me for a save location. The macro then saves the new Excel file, then it replaces the full path to Template.xls with the full path to the new Excel file ["sSaveName".xls]. The macro concludes with saving the updated Word document as sSaveName.doc. [Code available if needed]


So, my thought is this: Do an If/then from within my macro, appearing after the save of my sSaveName.xls file [so that the new full path is established] to look at Cell "A1" for the appropriate format of the field that is redundant [that is, assume A1 = "I" versus "We"]. The macro should capture this field and store it as a variable. The macro should then go into Word and do a find/replace for some "placeholder" like __I_or_We__ and replace all instances of the placeholder with the appropriate field.

Can anybody help with this?

Thanks in advance.

Hoop


Report Offensive Message For Removal


Response Number 1
Name: Razor2.3
Date: August 5, 2008 at 18:59:33 Pacific
Reply: (edit)

The macro should then go into Word and do a find/replace for some "placeholder" like __I_or_We__ and replace all instances of the placeholder with the appropriate field.
Shoot, go for it. You have the full path to the file, and you've demonstrated the ability to have one Office application call another. The only thing you'd need is the documentation on Word's find/replace.


Report Offensive Follow Up For Removal

Response Number 2
Name: 24HG_Hoop
Date: August 6, 2008 at 07:01:44 Pacific
Reply: (edit)

Thanks - sometimes its more about putting "pen to paper" explaining it to others that helps more than anything. I'm finally getting over the hump of kinda knowing what I'm doing with VB. Thanks for the help (past and present).


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History




Data Recovery Software