Conversion of VBA script for Word95 to Word 2002

J

JM7

The following is a script I developed years ago for Word 95 - it still works
fine and is the reason my typist uses WORD 95 (no real need to upgrade).

However, as I need to go to ACCESS2002/03 - I am thinking of moving on to
WORD 2002/03 as well.

Am I better off staying with VB Script or will the new macros in the latest
versions of WORD be better?

___The code script basically collects the text from a group of letters
puts/archives it into one file of template "pcopy" tagging each with a date
and then saving the file with a name that includes the current date.
________


Dim wd,n
Dim fso, f, f1, fc, s,h,nn, y, m, d
dim sh, snn, sn, sy, sm, sd

Set wd = CreateObject("word.basic")

wd.FileNew ("pcopy")

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("\\p266\c\my documents\practice letters\")
Set fc = f.Files
For Each f1 in fc
n=n+1
s = f1.name


wd.Insert Left(s, Len(s) - 4) + " .. " ' line16
wd.InsertDateTime "d MMM yy .. hh:mm:ss", 0
wd.ParaUp
wd.RightPara
wd.ParaDown

wd.InsertPara
wd.InsertFile "\\p266\c\my documents\practice letters\" + s, , , 0

wd.InsertBreak
Next

wd.editclear -1

y=datepart("yyyy",now)
m=datepart("m",now)
d=datepart("d",now)
h=datepart("h",now)
nn=datepart("n",now)


sy=right(formatnumber(y,0),2)

if m<10 then
sm="0"+ formatnumber(m,0)
else
sm=formatnumber(m,0)
end if

if d<10 then
sd="0"+ formatnumber(d,0)
else
sd=formatnumber(d,0)
end if

if h<10 then
sh="0"+ formatnumber(h,0)
else
sh=formatnumber(h,0)
end if

if nn<10 then
snn="0"+ formatnumber(nn,0)
else
snn=formatnumber(nn,0)
end if

if n<10 then
sn="0"+ formatnumber(n,0)
else
sn=formatnumber(n,0)
end if

wd.FileSaveAs "\\p266\c\my documents\archive\" + sy + sm + sd + "_" +
sh+snn + "_" + sn + ".doc"
wd.FilePrintSetup "Photocopier on Lexnet"



__________
 

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