Word 97 Macro, Not running correctly in word 2000

Hi,

I have a problem with a macro I wrote many moons ago. The problem is I struggled to get it working at the time and haven't touched it since as it worked quite well.

I have upgraded to office 2000 now and the problems I am getting are as follows:

Microsoft word err=1120
There is a printer error

A couple of things to note, the printer is connected locally and is called 'local'. There is also a mapping to h:\ locally. Tray 2 is also full of paper and I can print from here normally.

Ideally I'd like to change it so that the documents print to a network printer. One other thing is sometimes I get an error that the margins are outside the printable area of the page. Is there any way I can bypass this? If anybody could point me in the right direction I'd really appreciate it.....

The code is as follows:

Public Sub MAIN()
Dim Y$
Dim D$
Dim S$
Dim num$
Dim Count_
Dim logname$
Y$ = WordBasic.[Date$](WordBasic.Today() - 1)
D$ = WordBasic.[Date$](WordBasic.Today())
S$ = "h:\dummy.doc"

WordBasic.FileFind SearchName:="dummy", SearchPath:=S$, Name:="*.doc", SubDir:=0, Title:="", Author:="", Keywords:="", Subject:="", Options:=0, MatchCase:=0, Text:="", PatternMatch:=0, DateSavedFrom:=Y$, DateSavedTo:=Y$, SavedBy:="", DateCreatedFrom:="", DateCreatedTo:="", View:=0, SortBy:=4, ListBy:=0, SelectedFile:=0



WordBasic.FileNewDefault
WordBasic.FormatFont Points:=18, Underline:=1, Bold:=1
WordBasic.InsertDateField
WordBasic.Insert Chr(32)
WordBasic.Insert "                                 Dummy Dept (1st Floor) Documents"
WordBasic.Insert Chr(13)
WordBasic.Insert Chr(13)
WordBasic.Insert "                                           Total Documents printed =  "
WordBasic.Insert Chr(32)
num$ = WordBasic.[LTrim$](Str(WordBasic.CountFoundFiles()))
WordBasic.Insert num$
WordBasic.Insert Chr(13)
WordBasic.Insert Chr(13)
WordBasic.Insert Chr(13)
WordBasic.FormatTabs Position:="7.5 cm", Align:=0, Set:=1

Count_ = 0
On Error GoTo -1: On Error GoTo Finish
While Count_ <= WordBasic.CountFoundFiles()
    Count_ = Count_ + 1
    WordBasic.Insert WordBasic.[FoundFileName$](Count_)
    If Count_ / 2 <> WordBasic.Int(Count_ / 2) Then
    WordBasic.Insert Chr(9)
    Else
    WordBasic.Insert Chr(13)
    End If
Wend

logname$ = "H:\dummy.doc"
WordBasic.FileSaveAs Name:=logname$

WordBasic.FilePrintSetup Printer:="local"
WordBasic.ToolsOptionsPrint DefaultTray:="Tray 2"
WordBasic.FilePrint Background:=0, AppendPrFile:=0, Range:="0", PrToFileName:="", From:="", To:="", Type:=0, NumCopies:="1", Pages:="", Order:=0, PrintToFile:=0, Collate:=1, FileName:="H:\dummy.doc"


Count_ = 0
On Error GoTo -1: On Error GoTo Finish
While Count_ <= WordBasic.CountFoundFiles()
    Count_ = Count_ + 1
WordBasic.FilePrintSetup Printer:="Local"
WordBasic.ToolsOptionsPrint DefaultTray:="Tray 2"
WordBasic.FilePrint Background:=0, AppendPrFile:=0, Range:="0", PrToFileName:="", From:="", To:="", Type:=0, NumCopies:="1", Pages:="", Order:=0, PrintToFile:=0, Collate:=1, FileName:=WordBasic.[FoundFileName$](Count_)
Wend
Finish:
WordBasic.FileExit 1
End Sub


retro_questionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
I only get that error if it can't find the printer. Just changing the "Local" for our network print name got it working here.

You could drop the WordBasic and use the VBA equivalents:

ActivePrinter = "Network printer name"
Options.DefaultTray = "Tray 1"
ActiveDocument.PrintOut

0
GrahamSkanRetiredCommented:
Regarding the margins outside printable area. Have you checked both the margins in the Word Page Layout and those in the Printer Properties?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CleanupPingCommented:
Hi retro_questions,
This old question (QID 20568554) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.