Solved

VBA Trouble

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now