Solved

VBA Trouble

Posted on 1997-11-23
2
238 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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