473,414 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Vb-how To Moniter Changes Made In Excel By Using Vb 6.0 Software

HI all,

I wanted to monitor changes made in any excel file of each and every cell by various users in networking system.

kindly provide some guidelines how to create the software.

Regards
Anup kumar
May 15 '07 #1
14 1987
Killer42
8,435 Expert 8TB
I wanted to monitor changes made in any excel file of each and every cell by various users in networking system.

kindly provide some guidelines how to create the software.
It might be simplest to put something in the Worksheet_Change event of the worksheet(s) in question. For example, you could append an entry to a log (text) file each time.
May 16 '07 #2
It might be simplest to put something in the Worksheet_Change event of the worksheet(s) in question. For example, you could append an entry to a log (text) file each time.

I didn't get dear.

Plz explain this thing in a bit more broadway. As i am very much new to Vb.
May 16 '07 #3
Killer42
8,435 Expert 8TB
I didn't get dear.

Plz explain this thing in a bit more broadway. As i am very much new to Vb.
Ok, well in this case we'll actually be talking about VBA. That's "Visual Basic for Applications", which is a version of VB built into MS Office applications to do scripting (automating tasks) by writing "macro" code.

Let's have a go at throwing together a simple little example macro for Excel which will append the details of each change made to a worksheet into a text file.

To create this, follow the following steps. (Hopefully they won't vary too much on your system, but we'll see).
  • open a new worksheet in Excel.
  • Pull down the Tools menu, expand the [b]Macro submenu and select Visual Basic Editor.
  • In the Project Explorer window (the one probably at top-left which lists what's in the project) double-click on ThisWorkbook.
  • You should get a blank code window on the right.
  • At the top of the code window, pull down the left-hand listbox and select WorkBook.
  • Pull down the right-hand listbox and select SheetChange.
  • You are now in the code window for the workbook's SheetChange event procedure. Any code you enter here will be executed each time a change is made on any of the worksheets in this workbook.
  • Paste in the following code. This is a very simple example, but will provide you with a starting point. You can then take this code and play with it.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    2.   Dim W As Worksheet
    3.   Set W = Sh
    4.   Dim C As Range
    5.   Dim Fnum As Long
    6.   Fnum = FreeFile
    7.   Open "C:\Temp\ChangeLog.txt" For Append Access Read Write Lock Write As #Fnum
    8.   For Each C In Target.Cells
    9.     With C
    10.       'Debug.Print , W.Name, .Column, .Row, .Value, .Value2
    11.       Print #Fnum, W.Name; vbTab; .Column; vbTab; .Row; vbTab; .Formula; vbTab; .Value
    12.     End With
    13.   Next
    14.   Set W = Nothing
    15.   Set C = Nothing
    16.   Close #Fnum
    17. End Sub
    18.  
May 16 '07 #4
Ok, well in this case we'll actually be talking about VBA. That's "Visual Basic for Applications", which is a version of VB built into MS Office applications to do scripting (automating tasks) by writing "macro" code.

Let's have a go at throwing together a simple little example macro for Excel which will append the details of each change made to a worksheet into a text file.

To create this, follow the following steps. (Hopefully they won't vary too much on your system, but we'll see).
  • open a new worksheet in Excel.
  • Pull down the Tools menu, expand the [b]Macro submenu and select Visual Basic Editor.
  • In the Project Explorer window (the one probably at top-left which lists what's in the project) double-click on ThisWorkbook.
  • You should get a blank code window on the right.
  • At the top of the code window, pull down the left-hand listbox and select WorkBook.
  • Pull down the right-hand listbox and select SheetChange.
  • You are now in the code window for the workbook's SheetChange event procedure. Any code you enter here will be executed each time a change is made on any of the worksheets in this workbook.
  • Paste in the following code. This is a very simple example, but will provide you with a starting point. You can then take this code and play with it.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    2.   Dim W As Worksheet
    3.   Set W = Sh
    4.   Dim C As Range
    5.   Dim Fnum As Long
    6.   Fnum = FreeFile
    7.   Open "C:\Temp\ChangeLog.txt" For Append Access Read Write Lock Write As #Fnum
    8.   For Each C In Target.Cells
    9.     With C
    10.       'Debug.Print , W.Name, .Column, .Row, .Value, .Value2
    11.       Print #Fnum, W.Name; vbTab; .Column; vbTab; .Row; vbTab; .Formula; vbTab; .Value
    12.     End With
    13.   Next
    14.   Set W = Nothing
    15.   Set C = Nothing
    16.   Close #Fnum
    17. End Sub
    18.  

Ya thanx dear its working. But there is one problem, since this file is in networking system, i wanted the name of the User who will modify these changes. Is It possible?
May 16 '07 #5
Killer42
8,435 Expert 8TB
Ya thanx dear its working. But there is one problem, since this file is in networking system, i wanted the name of the User who will modify these changes. Is It possible?
Probably. Have a look through the properties that are available. Um... Application.UserName might be what you want.
May 16 '07 #6
Probably. Have a look through the properties that are available. Um... Application.UserName might be what you want.

Thanx a lot Dude.Gr8 mind.It has worked.One more favour if you can.I also want the Date and Time of changes made.Plzzzzzzzzzz help.
May 17 '07 #7
Killer42
8,435 Expert 8TB
Thanx a lot Dude.Gr8 mind.It has worked.One more favour if you can.I also want the Date and Time of changes made.Plzzzzzzzzzz help.
Check out the Now() function. And you may need to use Format() on it.

Um... Now is from VB6. In Excel, you might have to use something else. Check the doco for system date and time.
May 17 '07 #8
Check out the Now() function. And you may need to use Format() on it.

Um... Now is from VB6. In Excel, you might have to use something else. Check the doco for system date and time.

many many thanx to you.Its working.See you later. Bye bye
May 17 '07 #9
many many thanx to you.Its working.See you later. Bye bye

Hi,
Can u tell me now how can i get the "logfile" datewise.I mean i had specified a path of a text file.But is it not possible that certain VBA command can generate the text file automatcally datewise format.

Regards
Anup
May 19 '07 #10
Killer42
8,435 Expert 8TB
Can u tell me now how can i get the "logfile" datewise.I mean i had specified a path of a text file.But is it not possible that certain VBA command can generate the text file automatcally datewise format.
I don't understand what you mean by "generating a file datewise".
May 19 '07 #11
I don't understand what you mean by "generating a file datewise".
As when i type the below lines in the VBA In return it gives the changes made in the excel in changeLog.txt file.
Open "C:\Temp\ChangeLog.txt" For Append Access Read Write Lock Write As #Fnum

I want this file to automicatlly generate as "changelog" along with system date.
e.g. changelog2007.05.25 for a perticular day. Hope now you would have got what i want to say.
May 19 '07 #12
As when i type the below lines in the VBA In return it gives the changes made in the excel in changeLog.txt file.
Open "C:\Temp\ChangeLog.txt" For Append Access Read Write Lock Write As #Fnum

I want this file to automicatlly generate as "changelog" along with system date.
e.g. changelog2007.05.25 for a perticular day. Hope now you would have got what i want to say.

whats up.Was my question not understandable???Plz help me to get the things done.
May 21 '07 #13
Killer42
8,435 Expert 8TB
whats up.Was my question not understandable???Plz help me to get the things done.
Sorry, been very busy. Don't forget you're dealing with people in different timezones around the world who are volunteering their own time to help. So sometimes you need to be a bit patient.

All you need do is include the date in the string which names the file. For example...

Dim strFileName As String
strFileName = "C:\Temp\ChangeLog" & Format(Now, "yyyy-mm-dd" & ".Txt"
Open strFileName For Append Access Read Write Lock Write As #Fnum


You need to watch your terminology. It's just confusing things to say that the file is "automatically generating". The file is not doing anything. You want your code to generate a name for the file which includes the current date.
May 21 '07 #14
Sorry, been very busy. Don't forget you're dealing with people in different timezones around the world who are volunteering their own time to help. So sometimes you need to be a bit patient.

All you need do is include the date in the string which names the file. For example...

Dim strFileName As String
strFileName = "C:\Temp\ChangeLog" & Format(Now, "yyyy-mm-dd" & ".Txt"
Open strFileName For Append Access Read Write Lock Write As #Fnum


You need to watch your terminology. It's just confusing things to say that the file is "automatically generating". The file is not doing anything. You want your code to generate a name for the file which includes the current date.

Hi,
I got your point. But its not happening:
Look below the codes it seems fine to me.But it doesnot work at all.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim W As Worksheet

Set W = Sh

Dim C As Range

Dim Fnum As Long
Dim strFileName As String
strFileName = "C:\Documents and Settings\Anup\Desktop\book1.txt" & Format(Now(), "yyyy-mm-dd" & ".Txt")
Fnum = FreeFile
Open strFileName For Append Access Read Write Lock Write As #Fnum
For Each C In Target.Cells
With C
'Debug.Print , W.Name, .Column, .Row, .Value, .Value2,.Application.UserName
Print #Fnum, W.Name; vbTab; .Column; vbTab; .Row; vbTab; .Value; vbTab; Application.UserName; vbTab; Now(); vbTab
End With
Next

Set W = Nothing

Set C = Nothing

Close #Fnum

End Sub
May 21 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eric Clapton | last post by:
When should I use vb.net and when I should use c#.net? What is pros and cons?
14
by: Don Wash | last post by:
Hi There! In C# you can use /// to add comments that can produce XML documentation. What about in VB???? Thanks, Don
4
by: Tony Thijs | last post by:
C# or VB.net? When considering a complex Commerce Server clustered environment with over 500 K users expected, one of the fundamental choices to make is the programming language to be used....
5
by: thomas | last post by:
Hello, I wonder if it is possible to include visual basic class to a C++ project within a solution. Thanks Thomas
64
by: Milan | last post by:
Hello, I would like to ask you this question. I am experienced in programming in VBA and I want to upgrade my knowledge to Visual Studio 2005 now. I hesitate whether to aim to VB or C#. Since I...
4
by: pcnerd | last post by:
I've been playing around with VB since version 3. I now have VB6 Learning Edition. I'm thinking about getting VB.NET Express Edition. I have a lot of demo programs for version 3 thru version 6. I...
14
by: John Smith | last post by:
Can someone convert from C# into VB this line for me: if (c is System.Web.UI.HtmlControls.HtmlForm)
3
by: Dhananjay | last post by:
Hi All, I am facing problem when i am converting C#.net code(Delegate concept) into vb.net. I am unable to do that . Can someone help me to solve the problem. I am providing my C#.net code. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.