Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 43
Default 2 Macros running on same module

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

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 123
Default 2 Macros running on same module

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.

On May 5, 2:52 pm, Travis wrote:
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


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 43
Default 2 Macros running on same module

Thanks for the help. I'm still learning the VB thing, but i'll get it
straight.

"Reitanos" wrote:

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.

On May 5, 2:52 pm, Travis wrote:
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running VB macros gwtechie72 New Users to Excel 2 November 12th 07 10:04 PM
Running Macros Excel Discussion (Misc queries) 1 July 6th 06 04:21 PM
Running Macros Excel Worksheet Functions 0 July 6th 06 03:42 PM
Running Macros simpleS Setting up and Configuration of Excel 1 February 17th 05 02:32 PM
Two Macros-One Module BulaMan Excel Discussion (Misc queries) 2 December 16th 04 01:24 PM


All times are GMT +1. The time now is 08:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"