Solved

VBA Trouble

Posted on 1997-11-23
2
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

724 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