Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to log Excel macro operations in a log file

Posted on 2013-02-06
4
Medium Priority
?
235 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 2000 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:Tracy
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

715 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