Prefixing...

K

kiran

Dear All,

I have set of documents eg: in my d:\vss folder i have 10 documents with
diffrent name like
ab.doc
bc.doc
cd.doc
de.doc so on i want to prefix a number to these docs like
1ab.doc
1bc.doc
1cd.doc
1de.doc is there any way i can prefix in one shot or any program pls suggest

TIA
 
D

Doug Robbins

The following macro should do what you want, BUT, in case you get it wrong,
you SHOULD make a copy of all of the files first.

Dim MyPath As String
Dim MyName As String
Dim mydoc As Document

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Set mydoc = Documents.Open(MyPath & MyName)
mydoc.SaveAs MyPath & "1" & mydoc.Name
mydoc.Close
Kill MyPath & MyName
MyName = Dir$
Loop


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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