Retreive word string

M

Mark Belton

I've setup a DDE between Excel and Word to run a number of mail merges from
various excel sources as shown on
http://support.microsoft.com/default.aspx?scid=kb;en-us;274284

During the DDE link I've passed the Excel file path (e.g. c:\test.xls)
across to word and written this onto the word document (e.g. Data Source File
Path > C:\test.xls)

I'm trying to execute a mail merges using the passed file path as the data
source.

All is working, apart from me getting the file path value and using in the
mail merge procedured. I need the string value of the file path and I'm not
sure how to get it.

Is it possible to either:
(1) storing the file path in a temp file to retreive from any procedure ?
or
(2) extracting the file path as a string from the word document (find??) and
using in the vba code?

Many thanks in advance

mark
 
M

Mark Belton

I'm managed to extract the text from the word doucment as a string using the
code at the bottom of this post.

However, this is returning the required string with a with a picture of a
square at the end of it, which I assume is a carriage return indicating the
next paragraph.

e.g. C:\Test.xls [] < brackets are indicating the square

I've tried the trim command, but the square stays. This is causing the
remaining procedure to fail.

Can someone help me remove the square from my string? PLEASE!!!

This is the last thing I need to do before it all works!

CODE SAMPLE
=============================
Sub DataSourcePath()

Dim strDataSourcePath As String

iParCount = ActiveDocument.Paragraphs.Count

For j = 2 To iParCount
smypar = ActiveDocument.Paragraphs(j).Range.Text
ActiveDocument.Paragraphs(j).Range.Text = smypar

strDataSourcePath = smypar

Exit For
Next j
'pass argument to DoMerge
DoMerge strDataSourcePath
End Sub
=============================
 
C

Chuck

Have you explored the following in VBA Help:

Path property
Name property
Fullname property
PathSeparator property

They should give you all the information you need.

Without seeing your code it's impossible to say how best to implement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top