Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[curious] Echo "Hello World" VB script output into Word

Status
Not open for further replies.

mattsv

Programmer
May 21, 2005
28
US
How does one go about doing something like this:

I author some VB code where I write "Hello World", then have the output text echo to a particular part of a word document?

So that "Hello World" can appear within a paragraph of text which was already composed in MS Word.


Keywords: embed VB in word, execute VB within Word,
 
Why would you want to do this?

Sounds like a malicious prank to play on someone...

Cheers,
Dave

Probably the only Test Analyst on Tek-Tips...therefore whatever it was that went wrong, I'm to blame...

animadverto vos in Abyssus!

Take a look at Forum1393 & sign up if you'd like
 
Actually, it's not a prank. Here's what I'm doing:

I have two database tables within an Access database. My mail merge inserts into my document by iterating through one of the tables.

However, to get all the data, I need to do a join and link each tuple from table 1 to it's corresponding tuple in table 2.

I haven't had success with {DATABASE /d}. I added an ODBC source. I can't troubleshoot the error messages ( I get because it seems you can't do 2 sources at once, MS just recommends using DDE (dynamic data exchange). MS recommends just making a Query in MS Access and merging from that. Doing that would be easy, I just wanted to try out doing something this way and learn from it.


So I figured: I'll leave the mail merge as is, and write some vb DLookup code and echo out to the word document.

I've seen people write on the internet about how to echo to Word within VB. However, I haven't seen the other way. It might not be possible.


If this fails, I'll just rip out the mail merge as is and use MS Query or merge from an Access Query. I was just hoping for a quick hack to this and to try out something that I could learn from.
 
Hi mattsv,

You can write text to a document in all sorts of ways but what you must do first is identify the point in the document where you want to do it. The easiest method is normally to have a bookmark but this might be a bit awkward in a mail merge document if you want to write into the middle of some merged text. Could you give a few more details of how you want the text integrated.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
> might be a bit awkward in a mail merge document if you want > to write into the middle of some merged text.

Good call!

However, I'm not modifying any text within fields that are merged in. The text is already finished- it was input and crafted within MS Access forms.

I'm just trying to paste text from 2 different tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top