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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA To Open a Word doc using wilcards

Status
Not open for further replies.

ormsk

Programmer
Sep 30, 2002
147
GB
Hi

I know how to open a Word doc using VBA when there is a specific filename to open.

However, the Word doc I want to open is an amalgamation of data from the existing record of a query.

e.g.

The files were save as CustomerName & " - " & anInteger & " - " & anotherInteger

as an example

Which might give a doc name as "Microsoft - 012 - 001"

However, since the name of the various companies are variable in length, the only 'absolutes' are the two integer values.

I want to be able to open a file (without a dialog appearing) that opens a file "*-" & " - " & anInteger & " - " & anotherInteger

As the last two integers are make the document unique.

I have to do it this way as customer names may change, but original documents will still refer to the original customer name.

Thx
 
Ormsk,

Need more info ...

Are the Word docs always in the same place?
Do they reside with other (already processed) docs?
In your context, do you know a specific customer name?
Do you really need to extract the 2 ints from the name?

Wayne
 
Wayne

The Word docs are in the same place.

Just to explain further...

A recordset is used to view quotes already generated. For each record, there will be a word doc.

I want to be able to print preview any record the user chooses, so I have to 'locate' the specific word doc.

Upon generation, each word doc filename includes Customer Name, and various unique ID's.

However, a customer may change their name after a word doc has been generated so I cannot rely on re-building the filename from existing data in the current record(I don't want to store origination name in any table).

The ID's (integers etc) are unique, but form the end of the filename, hence the wildcard usage.

I know I can get around the problem by storing the original customer name somewhere, but this problem is useful if I can solve it (with others help).

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top