Help Needed

M

maddy

Hell Everubody

I am silent member of this group. i have one query for u ..

I am developing a software using visual basic , This softwarte is for
applying macros to all word files in a folder..

I have completed all the macro functions and i am able to imply the
functions on only one file... But i am not able to apply to next files
.... but all the files in the folder opens without apllying the
functions

so can anyone provide me a soln for this

thanks in advance

Do While Len(sWkg)
If sAns(0) = "" Then
sAns(0) = sWkg

OpenWord (sWkg)
'MsgBox "first file"
Else
lCtr = UBound(sAns) + 1
ReDim Preserve sAns(lCtr) As String
'msgbox "second file "
sAns(lCtr) = sWkg

OpenWord (sAns(lCtr))

End If

sWkg = Dir

Loop
the above is the code where i open the files
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Maddy:

Nice to hear from you finally :)

I think your answer is here in the VBA Help:

To iterate over all files in a folder, specify an empty string:

Dir("")

You must specify pathname the first time you call the Dir function, or an
error occurs. If you also specify file attributes, pathname must be
included.

I would add a MsgBox command immediately after your Dir command to report
what is being returned by the Dir command. I am not sure whether you get
the fully-qualified filename or just the file name without a path.

Nor can I tell from your code what your OpenWord function requires. But if
it's built around the Documents.Open function, it requires a fully qualified
name. Or rather: If you do not specify the fully-qualified pathname, in
colon-separated format, you need to be sure you KNOW what the Application
Current Directory attribute is set to, because it does not automatically
follow the opened document like it does on Windows.

Hope this helps

Hell Everubody

I am silent member of this group. i have one query for u ..

I am developing a software using visual basic , This softwarte is for
applying macros to all word files in a folder..

I have completed all the macro functions and i am able to imply the
functions on only one file... But i am not able to apply to next files
... but all the files in the folder opens without apllying the

functions

so can anyone provide me a soln for this

thanks in advance

Do While Len(sWkg)
If sAns(0) = "" Then
sAns(0) = sWkg

OpenWord (sWkg)
'MsgBox "first file"
Else
lCtr = UBound(sAns) + 1
ReDim Preserve sAns(lCtr) As String
'msgbox "second file "
sAns(lCtr) = sWkg

OpenWord (sAns(lCtr))

End If

sWkg = Dir

Loop
the above is the code where i open the files

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410
 

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