VBA code won't run on an NT machine? (SOLVED)

kskinne

Well-known Member
Joined
Feb 17, 2002
Messages
1,267
Office Version
  1. 365
Platform
  1. Windows
I have a bit of VBA code that works fine on my w2k machine using office 2000, but will not work on an NT4 machine using office 97. the code is:

Sub Auto_Open()
If Application.UserName<> "miiiy" Then End
Application.ScreenUpdating = False
ChDir "S:TREND ANALYSIS"
Workbooks.Open Filename:="S:TREND ANALYSISLINEAR TREND-ALL.XLS", UpdateLinks:=3
Workbooks.Open Filename:="S:TREND ANALYSISStatistics - condensed for Board-2002.xls", UpdateLinks:=3
Workbooks("customer activity 2002.xls").Activate
Range("A1").Select
Application.ScreenUpdating = True
End Sub

any idea as to why this code would work in one but not in the other?

thanks
kevin
This message was edited by kskinne on 2002-10-22 16:39
This message was edited by kskinne on 2002-10-22 16:59
This message was edited by kskinne on 2002-10-22 17:00
This message was edited by kskinne on 2002-10-29 09:57
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi kskinne,

I see nothing in your code that shouldn't work just as well on NT as Windows XX. I would suggest you debug the code--at least to the point of finding out exactly which line it fails on. You can do this by putting a debug breakpoint (get the Debug toolbar in the VBE if you don't already have it), and then executing the Open event macro manually (put your cursor in the macro and click the Run button). You can then single-step thru the code using the single-step button on the Debug toolbar until it fails.

My guess is that one of the file path names is incorrect.

If it still isn't obvious what the problem is once you get it isolated to a particular line of code, try posting on the board again with this additional information.
 

SamS

Well-known Member
Joined
Feb 17, 2002
Messages
542
Kevin, the code works on my NT4 and excel 97, what I suspect is that your Username is not the same as what is stored in Excel ie you are trying to use the NT4 login Id. To confirm it is correct go to Tools>Options>General and check what username is being used by Excel.

Edit: also look closely at what Damon suggested. I suggest you try and use the actual server path ie instead of S:etc use \ntco02myserveretc. This helps particularily if you map to different servers.

_________________<font size=+1.<fontcolor="Blue">Sam</font size=+1.</fontcolor="Blue">
Why is it that the nuttiest people define reality?
This message was edited by SamS on 2002-10-22 17:31
 

kskinne

Well-known Member
Joined
Feb 17, 2002
Messages
1,267
Office Version
  1. 365
Platform
  1. Windows
found out what it was - Sam S, I took your advice and double-checked the name that the other computer's version of excel was licensed to, and it was the same, EXCEPT that the first letter was capitalized. apparently, the application.username line of code is case-sensitive, so after I changed that, everything worked just as it should

thanks for the help,
kevin
 

Forum statistics

Threads
1,144,768
Messages
5,726,181
Members
422,660
Latest member
mrsteele

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top