Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / May 2008

Tip: Looking for answers? Try searching our database.

2 Macros running on same module

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Travis - 05 May 2008 19:52 GMT
I have a problem with having 2 macros in the same ThisWorksheet code area.  I
have a macro that logs who opened my workbook and one that on open selects
the first sheet i specified.  My problem is it only opens the first macro.  
When i change the second macro to Workbook_Open it says i can't have 2 of the
same arguements.  Is there a way to write this so they both open with no
conflicts?

Option Explicit

Sub Workbook_Open()
   
Sheets("Front Page").Select
   
End Sub
Sub Auto_Open()

' Use as part of an Auto_Open macro
' Change both occurances of C:\myExcelBackups to the desired
' path location for the File Use Log -i.e. a network drive?
' A text file will show the name and time of everyone who
' opens the workbook.

Application.DisplayAlerts = False
Dim FileUser As String
Dim FileUserDocFILE As String
FileUser = ActiveWorkbook.Name
On Error Resume Next
MkDir "MYWORKBOOK"
FileUserDocFILE = "MYWORKBOOK" & FileUser & " Log.txt"
On Error GoTo 0
Open FileUserDocFILE For Append As #1
Print #1, Application.UserName & Environ("username") & " Opened " &
ActiveWorkbook.Name & " at " & Now
Close #1
Application.DisplayAlerts = True
End Sub
Reitanos - 05 May 2008 20:01 GMT
Is there a reason that you don't just call the other macro at the end
of the first one? You can type the name of the second macro before the
End Sub line.

> I have a problem with having 2 macros in the same ThisWorksheet code area.  I
> have a macro that logs who opened my workbook and one that on open selects
[quoted text clipped - 32 lines]
> Application.DisplayAlerts = True
> End Sub
Travis - 06 May 2008 12:46 GMT
Thanks for the help.  I'm still learning the VB thing, but i'll get it
straight.

> Is there a reason that you don't just call the other macro at the end
> of the first one? You can type the name of the second macro before the
[quoted text clipped - 36 lines]
> > Application.DisplayAlerts = True
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.