Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Generates Fatal Error Message - Excel 97

Status
Not open for further replies.

dunkyn

Technical User
Apr 30, 2001
194
US
I created the following label print macro in Excel XP. It works great. However, when I gave it to Excel 97 users I get a fatal error and the application shuts down. Ironically, if I open the Visual Basic Editor and hit F8, the application runs fine, but if I assign the macro to a Form Commandbutton, I get the following error message:

EXCEL caused an invalid page fault in
module <unknown> at 0000:53ec8b55.
Registers:
EAX=008c19fc CS=0177 EIP=53ec8b55 EFLGS=00010206
EBX=00000009 SS=017f ESP=0062e284 EBP=0062e2c0
ECX=00000001 DS=017f ESI=0062e2ac FS=463f
EDX=0001000b ES=017f EDI=00620009 GS=0000
Bytes at CS:EIP:

Stack dump:
6534231d 008c19fc 0062e2a0 00000000 00a7d20c 3047ddcc 0062e2ac 0062e2dc 0062e308 3002c10c 00000009 0062e2cc 008c19fc 000000e0 65343dbf 0062e324

I suspect the issue is the different versions of Excel. Does anyone know how to make this work in Excel 97?

Another oddity is that the spreadsheet won't calculate when it is set on Automatic Calculation. You have to hit F9 to force the calculation.

Here is my macro:

Sub FTCLabelMacro()

Dim LabelStartRow As Integer
Dim LabelEndRow As Integer
Dim LabelMsg As String
Dim k As Integer

Sheets(&quot;FTC Label&quot;).Activate
LabelStartRow = Range(&quot;LabelStartRow&quot;)
LabelEndRow = Range(&quot;LabelEndRow&quot;)

If LabelStartRow > LabelEndRow Then
LabelMsg = &quot;ERROR&quot; & Chr(13) & &quot;The starting row must be less than the ending row!&quot;
MsgBox Msg, vbCritical, &quot;FTC Address Labels&quot;
End If

For k = LabelStartRow To LabelEndRow
Range(&quot;LabelRowIndex&quot;) = k
ActiveSheet.PrintOut Copies:=1
Next k

End Sub

Any assistance is greatly appreciated. I don't think these users will be getting Excel XP for some time.

TIA
 
Try saving it as an Access97 workbook. The Save As Type in the dialog box gives you other options.

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top