Solved

VBA Trouble

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 connector to SQL Server 2 37
Problem to With line 4 63
Send outlook email from VBS Script 2 44
adding "ungroup sheets" to existing vbs code 5 31
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

829 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