Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need some help with this macro plzzz!!
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need some help with this macro plzzz!!
If you know the fully qualified filename, then there is no searching
involved. You just open the file. -- Regards, Tom Ogilvy "Maria" wrote in message oups.com... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Need some help plzzz | Excel Programming | |||
"IF Condition" formula.... any help plzzz?! | Excel Discussion (Misc queries) | |||
Excel Help with pictures plzzz | Excel Discussion (Misc queries) | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |