Need some help with this macro plzzz!!

M

Maria

Hey guyz can someone plz help a beginner with some macros here!!
I need a macro to "read" text or "file name" from an excel sheet ,
search the directory or any path defined. locate the document and
insert it in a word doc( predefined word doc.)

I know I sound confusing, This macro is basically suppose to help in
creating proposals in word from price sheets in excel.
I got this code: It sort of does what i want but i need your help in
some modifications plzzz.

Sub DirLoop()
Dim MyFile As String, Sep As String, filename1 As String
filename1 = "H:\2006\Course Description\AIX 5L"
' Sets up the variable "MyFile" to be each file in the directory
' This example looks for all the files that have an .xls extension.
' This can be changed to whatever extension is needed. Also, this
' macro searches the current directory. This can be changed to any
' directory.
' Test for Windows or Macintosh platform. Make the directory request.
Sep = Application.PathSeparator
If Sep = "\" Then
' Windows platform search syntax.
MyFile = Dir(filename1 & Sep & "*.doc")
Else
' Macintosh platform search syntax.
' MyFile = Dir("", MacID("XLS5"))
End If
' Starts the loop, which will continue until there are no more files
' found.
Do While MyFile <> ""
' Displays a message box with the name of the file. This can be
' changed to any procedure that would be needed to run on every
' file in the directory such as opening each file.
MsgBox filename1 & Sep & MyFile
MyFile = Dir()
Loop
End Sub
This macro DOES NOT search it reads and displays every singal file name
in the directory. problem is I want it to search for the specific file
name given and insert it in the word template rather then reading and
displaying all file names in msgboxs
can any one help plzz.
Thanx
regards
Maria
 
T

Tom Ogilvy

If you know the fully qualified filename, then there is no searching
involved. You just open the file.
 

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