Solved

How to log Excel macro operations in a log file

Posted on 2013-02-06
4
184 Views
Last Modified: 2013-12-14
I have made visual basic macros in an Excel which are run on Auto_Open. IS there a simple script available to log operations in the Excel file and possible error messages from macro operations to a log file?
0
Comment
Question by:ecgabrielsen
4 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 38858440
You would have to use a general routine for logging the error and call it from an error handler in each routine. If you want to log the routine name, you would have to hardcode that into the error handler for each routine too.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38858448
here's a simple log subroutine which accept log file name and data:
 
Sub Log(file As string, data As string)
    Const ForReading = 1, ForWriting = 2
    Dim FSO As Object, TS As Object, TextLine As String, FN As String
    
    FN = file
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set TS = FSO.OpenTextfile(FileName:=FN, IOMode:=ForAppending, Create:=True)
    TS.WriteLine data
  
    TS.Close
    Set TS = Nothing
    Set FSO = Nothing
End Sub

Open in new window

0
 
LVL 24

Expert Comment

by:broomee9
ID: 39718535
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now