Excel Tip .com / Excel Tips and Tricks
      "... the easiest to understand excel book ..."     excel : excel tips : microsoft excel : excel tutorial : excel template : excel formula : excel macro : excel help : excel password : vba excel : excel spreadsheet : excel tool : excel download : microsoft excel download : excel 2000 : excel visual basic : ms excel : excel tip : free download excel : microsoft excel tutorial : excel training : free excel template : microsoft excel help : free excel : excel password recovery : microsoft excel 97 : excel 2000 tutorial : excel 97 : excel center : excel downloads : excel recovery : excel software : excel pivot table : excel book
ExcelTip.com Home Page Tip of the Hour Recommended Microsoft Excel Tips Most Viewed Microsoft Excel Tips at ExcelTip.com Excel Tip Categories Excel Tips by Version Submit a Tip My Bookmarked Tips Discount Book Store
Over 752,108 tips served







FREE DOWNLOAD

ExcelTip.com Free Add-In

SUPPORT EXCELTIP.COM

Make your Amazon.com purchases by clicking the graphic below

Excel Tip .com - Mailing List Thread Index


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating an error log



Steve & Sandy,
This is more than you asked for but...
It will create a file named ErrorLog.txt
Each line of the file will contain...
Your Error message
the computer the user was on when the error was found,
the user's login,
When the error was found,
the path and name of the workbook that contained the error

HTH,
Kevin

'*** Code Start ***
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nsize As Long) As Long

Declare Function GetComputerName& _
Lib "kernel32" Alias "GetComputerNameA" (ByVal lbbuffer As String, nsize
As Long)

Function ReturnCPUname()
'Find the computer name
Dim CPUname As String
Dim i As Integer
Dim z As String * 64
Call GetComputerName(z, 64)
ReturnCPUname = z

For i = 1 To Len(ReturnCPUname)
If Asc(Mid(ReturnCPUname, i, 1)) = 0 Then
ReturnCPUname = Left(ReturnCPUname, i)
Exit For
End If
Next i


End Function

Sub ErrorLog()
Dim CurUser As String
Dim buffer As String * 100
Dim BuffLen As Long
Dim MyPath As String
Dim FileNum As Integer
Dim i As Integer

'Find the computername
MsgBox Len(ReturnCPUname)

'Find your desktop and put the error log there
'Requires a refernce to the Windows Script Host Object Model
Dim WSHShell As IWshRuntimeLibrary.IWshShell_Class
Set WSHShell = New IWshRuntimeLibrary.IWshShell_Class
MyPath = WSHShell.SpecialFolders.Item("Desktop")

'You can change the MyPath = to match where you want the log

'Find the User Name
BuffLen = 100
GetUserName buffer, BuffLen
CurUser = Left(buffer, BuffLen - 1)

FileNum = FreeFile

'Start your loop here...
'For each...In...your range

'if your error then
Open MyPath & "\ErrorLog.txt" For Append As FileNum
'This will write in your ErrorLog.txt
'Your Error, the computer the user was on, the user's login, when, the
path and name of the workbook
Write #FileNum, "Error", ReturnCPUname, CurUser, Now, ThisWorkbook.Path
& "\" & ThisWorkbook.Name
Close FileNum
'continue your loop
End Sub

'*** Code End ***

-----Original Message-----
From: MS Excel General Q & A List [mailto:EXCEL-G@PEACH.EASE.LSOFT.COM]
On Behalf Of Steve Snow
Sent: Thursday, September 18, 2003 4:58 PM
To: EXCEL-G@PEACH.EASE.LSOFT.COM
Subject: [EXCEL-G] creating an error log


I would appreciate a bit of basic start help to do the following.

I want to be able to check a worksheet (size is about 43 columns by 159
rows).

Each cell has either numeric or text values (no mixing) and should have
limits.

I can do all the criteria things but how would I create a txt file (thus
how do I do the read/write part of the text file)?

Thus - as the error routine checks each cell - how do I get it to write
to a text file (one line) - e.g "Sept 1 0600 dry bulb (then the error
type), (new
line) Sept 4 1500 max temp (then the error) etc?

Thanks

Steve and Sandy Snow

------------------------------------------------------------------------
--
The EXCEL-G list is hosted on a Windows NT(TM) machine running L-Soft
international's LISTSERV(R) software.  For subscription/signoff info and
archives, see http://peach.ease.lsoft.com/archives/excel-g.html .
                             COPYRIGHT INFO:
http://peach.ease.lsoft.com/scripts/wa.exe?SHOWTPL=COPYRIGHT&L=EXCEL-G

--------------------------------------------------------------------------
The EXCEL-G list is hosted on a Windows NT(TM) machine running L-Soft
international's LISTSERV(R) software.  For subscription/signoff info
and archives, see http://peach.ease.lsoft.com/archives/excel-g.html .
                             COPYRIGHT INFO:
http://peach.ease.lsoft.com/scripts/wa.exe?SHOWTPL=COPYRIGHT&L=EXCEL-G





Amazon.com $35.95
MrExcel.com $24.95
Barnes & Noble $28.76
And at your local bookseller





Excel Training Level I
Excel Training Level II
Excel Training Level III
Excel VBA Training Level I
Excel VBA Training Level II
View All Excel Training Programs




Formula Manager
Duplication Manager
Text Manager
Number Manager
Add-ins Collection
Spreadsheet Assistant
Number Manager
Add-ins Collection
Spreadsheet Assistant

View All Excel Add-Ins

Tips

Add-In in VBA | Applications - Word, Outlook in VBA | Array Formulas | Cells, Ranges, Rows, and Columns in VBA | Counting | Custom Functions | Custom Functions in VBA | Database Formulas | Database in VBA | Date & Time Formulas | Date & Time in VBA | Events in VBA | Excel Chart | Excel Consolidating | Excel Counting | Excel Custom Functions using VBA | Excel Customizing | Excel Data | Excel Dates | Excel Editing | Excel Files | Excel Filter | Excel Format | Excel Formula | Excel General | Excel Grouping and Outlining | Excel Importing Text Files | Excel Information | Excel Keyboard Shortcuts | Excel Loan Formulas | Excel Macros - VBA | Excel Pivot Tables | Excel Printing | Excel Range Name | Excel Security - Protection | Excel Sorting | Excel Style | Excel Subtotals | Excel Summing | Excel Text | Excel Time | Excel Tools | Excel Worksheet, Workbook | Files, Workbook, and Worksheets in VBA | Financial Formulas | Formating in VBA | General Topics in VBA | Import and Export in VBA | Information Formulas | Keyboard & Other Shortcuts in VBA | Keyboard Formula Shortcuts | Links between Worksheet and Workbooks | Links in VBA | Logical Formulas | Lookup Formulas | Mail - Send and Receive in VBA | Menus, Toolbars, Status bar in VBA | Modules, Class Modules in VBA | New Excel 11, Excel 2003 | Other Q&A Formulas | Printing in VBA | Protecting in VBA | Summing | Text Formulas | User Forms, Input boxes in VBA | Using Loops | Working with Formulas |

Tips by Version

Microsoft Excel 97 | Microsoft Excel 2000 | Microsoft Excel 2002 | All Microsoft Excel Versions | New in Excel 2002 | New in Excel 2003 - Office 11

Website

Home | Tip of Hour | Recommended Tips | Most Viewed Tips | Tips by Version | Submit a Tip | My Tips
Microsoft Excel Tutorials | Excel Links | Write for Us | About Us | Search Results | Tip Archives

Excel Book

Excel 97 Book | Excel 2000 Book | Excel 2002 Book | Excel XP Book | Book Store

Terms and Conditions of use
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Copyright © 2003 ExcelTip.com
Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation
Site Developed By: Irubin Consulting


excel : excel tips : microsoft excel : excel tutorial : excel template : excel formula : excel macro : excel help : excel password : vba excel : excel spreadsheet : excel tool : excel download : microsoft excel download : excel 2000 : excel visual basic : ms excel : excel tip : free download excel : microsoft excel tutorial : excel training : free excel template : microsoft excel help : free excel : excel password recovery : microsoft excel 97 : excel 2000 tutorial : excel 97 : excel center : excel downloads : excel recovery : excel software : excel pivot table : excel book