Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Unable to Open File Error

I don't think I'd bother the user.

Maybe you can use the application.username (although sometimes it says important
things like: "Valued Gateway customer"!)

Or you could use the network id.

Maybe you can take some stuff from this:

Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX < 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 255
strCompName = String$(lngLen - 1, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX < 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If
End Function
Sub auto_open()
Dim DestCell As Range

With Worksheets("HiddenLogSheetNameHere")
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

With DestCell
.Value = fOSUserName
.Offset(0, 1).Value = Application.UserName
.Offset(0, 2).Value = fOSMachineName
With .Offset(0, 3)
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
End With
End Sub



Michael Lockwoo wrote:

Ok, Ladies and Gentlemen,

I'm at my wits end with this.

I have a excel file that uses the Workbook_open event to pop up a
inputbox asking for the individual's initials so I can log their
activity. This is placed in a hidden cell and used to call at will.

With that input box, when the file is opened, an error comes up telling
me it's unable to open/read the file and then repairs it and strips my
pivottable out of the worksheet.

Without the inputbox, the file works fine, as intended.

Any ideas?

Michael J. Lockwood

--
Michael Lockwoo

------------------------------------------------------------------------
Michael Lockwoo's Profile: http://www.excelforum.com/member.php...o&userid=31811
View this thread: http://www.excelforum.com/showthread...hreadid=551993


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Cannot access read-only document" (I get this error when I try to open an Excel file) [email protected] Excel Discussion (Misc queries) 1 June 5th 06 01:15 PM
error: "invalid character in text conent" How do I open this file RTH Excel Discussion (Misc queries) 5 April 23rd 06 03:04 PM
Unable to open file samb Excel Discussion (Misc queries) 0 March 16th 06 09:35 AM
Trying to open a file and receiving this error. John J. Excel Discussion (Misc queries) 1 March 4th 05 07:04 PM
Sumif Linking to Another Workbook error #VALUE! Tunde Excel Discussion (Misc queries) 16 March 4th 05 03:02 AM


All times are GMT +1. The time now is 03:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"