Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Word 97 Macro, Not running correctly in word 2000

Posted on 2003-03-31
3
Medium Priority
?
841 Views
Last Modified: 2012-06-21
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


0
Comment
Question by:retro_questions
  • 2
3 Comments
 
LVL 77

Expert Comment

by:GrahamSkan
ID: 8238459
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
 
LVL 77

Accepted Solution

by:
GrahamSkan earned 150 total points
ID: 8238760
Regarding the margins outside printable area. Have you checked both the margins in the Word Page Layout and those in the Printer Properties?
0
 

Expert Comment

by:CleanupPing
ID: 8531271
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question