How to find worksheet

C

Curt

Have an Excel workbook trying to use a worksheet in the workbook for mail
merge. Know its my code . will not locate (MailE.xls) as data source. Here is
code line. Will some one hit me in the face so I can see what I am missing.
Excel folder is Parade also Parade is file in folder Have tried
"C:\parade\parade\MailE.xls" ThankMailE is merge doc.
Thanks

ChangeFileOpenDirectory "C:\Parade"
Documents.Open FileName:="ThankMailE.doc", ConfirmConversions:=False, _


ActiveDocument.MailMerge.OpenDataSource Name:="C:\Parade.xls\MailE.xls",
 
R

Russ

You have to enter the Windows path to that folder. What do you use outside
of Word in Windows Explorer to get to that file?
 
R

Russ

One trick that I like to use to get a path, is to open a Dos window and
separately through Windows Explorer go to a file, then drag and drop that
file from Explorer on top of the Dos window. The full path to that file will
appear in the Dos window and you can copy it to the clipboard for pasting.
This works great for network paths, too.
To open a Dos window, go to Start button in Windows, click on Run, enter
cmd.
 
C

Curt

path shows up as you stated all I need is to get into file for a worksheet it
is a Excel worksheet in Parade.xls
 
R

Russ

I typed in opendatasource into Word VBA Help and the opendatasource method
help had this snippet of help for the connection parameter:

****Quote
Connection Optional Variant. A range within which the query specified by
SQLStatement is to be performed. How you specify the range depends on how
data is retrieved. For example:
€ When retrieving data through ODBC, you specify a connection string.
€ When retrieving data from Microsoft Excel using dynamic data exchange
(DDE) (Windows only), you specify a named range.
€ When retrieving data from Microsoft Access (Windows only), you specify
the word "Table" or "Query" followed by the name of a table or query.
****UnQuote

So create a named range for the worksheet data in Excel and pass that as the
Connection parameter. And maybe a SQLStatement query on that range is not
actually needed, so try it first without using a SQLStatement.
 
C

Curt

Gaining on operation noe I am looking as to where I create another OLE app.
Waiting to complets. Any way thanks your expl sure helped
 

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

Similar Threads

deleteing peoblem 5
4198 debug 0
Printer not there 1
Double return 0
delimiter settings 0
macro 2 issues 0
double merge 2
Word macro that can call cells out of Excel for a find and replace 0

Top