Solved

VBA Trouble

Posted on 1997-11-23
2
235 Views
Last Modified: 2008-03-04
I have some code that was written for Excel 7.0 and Word 7.0 but now we use Office 97.

I haven't had to modify any of the code as it appears to work fine however when in Word the cursor doesn't move to the designated bookmarks when required and when printing the Word document I have all the indications of the document printing but nothing comes out of the printer!!!

The code follows:

Sub PrintInvoice()

  Sheets("Account register").Select

  If Selection.Rows.Count <> 1 Or Selection.Columns.Count <> 256 Then
        MsgBox "You have not made a valid selection!  Please select the row " _
        + "which contains the data for the invoice you want to print." _
        , 48, "Invalid Selection"
        Exit Sub
  End If
       
  Set Word7 = CreateObject("Word.Basic")
  RowRef = Selection.Row

  RFI$ = Cells(RowRef, 1)
  RFIDate$ = Cells(RowRef, 2)

  Application.ActivateMicrosoftApp xlMicrosoftWord
       
  With Word7
        .ScreenUpdating 0
        .AppMaximize 1
        .FileOpen "c:\blank.doc"
        .ViewZoomWholePage
   
        .EditGoTo "RFI"
        .Insert RFI$
        .EditGoTo "Date"
        .Insert RFIDate$
       
        .ScreenUpdating 1
    Answer = .MsgBox("Are you sure you want to print the invoice?", _
                    "Print Invoice", 36)
       
    If Answer = -1 Then
      .ToolsOptionsPrint , , 1
      .FilePrint , , , , , , , , , 2
    End If
       
        .ViewNormal
        .FileClose 2
    If .CountWindows() = 0 Then .AppClose
  End With
 
  Set Word7 = Nothing
  AppActivate "Microsoft Excel"

End Sub
0
Comment
Question by:Geoffro
2 Comments
 

Author Comment

by:Geoffro
ID: 1442161
Adjusted points to 250
0
 
LVL 8

Accepted Solution

by:
mrmick earned 250 total points
ID: 1442162
There are differences in Word97 VBA and Word 7 WordBasic.  Word97 will read a macro in Word 7 format and convert it to the appropriate  Word97 format.  Try creating a macro in Word7 using the above code, import it into Word97, and see if the necessary changes are revealed.

A second suggestion, I may be a bug... there is an Office97 service pack release available on the net at:

   www.microsoft.com/OfficeFreeStuff

click on:

   Office 97 Service Release Ready for Download!


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now