Solved

How to log Excel macro operations in a log file

Posted on 2013-02-06
4
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

726 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