Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Macro that opens a separate workbook to a specified worksheet whenthe active workbook is right mouse clicked

I have a macro that opens a separate workbook when I right mouse click
but I want it to open to a specified sheet named "Wizard". It opens
the workbook by reading the string text displayed in M373 (see below).

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
Dim VHM As Workbook
Set VHM = ActiveWorkbook
Dim exlApp As Excel.Application
Set exlApp = New Excel.Application
exlApp.Visible = True
exlApp.Workbooks.Open Worksheets("DataBase").Range("M373")
VHM.Activate
Cancel = True
End Sub

Thanks for any help you can offer.

Michael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Macro that opens a separate workbook to a specified worksheetwhen the active workbook is right mouse clicked

I like to keep it simple. Just recorded and edited this

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 12/19/2011 by Donald B. Guillett
'

'
Workbooks.Open(Filename:= _
"C:\yourfoldername\yourfilename.xls", _
UpdateLinks:=3).RunAutoMacros Which:=xlAutoOpen
Sheets("yoursheetname").Select
Range("A12").Select
End Sub



On Dec 19, 12:53*pm, Michael Lanier wrote:
I have a macro that opens a separate workbook when I right mouse click
but I want it to open to a specified sheet named "Wizard". It opens
the workbook by reading the string text displayed in M373 (see below).

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
* * * * Dim VHM As Workbook
* * * * Set VHM = ActiveWorkbook
* * * * Dim exlApp As Excel.Application
* * * * Set exlApp = New Excel.Application
* * * * exlApp.Visible = True
* * * * exlApp.Workbooks.Open Worksheets("DataBase").Range("M373")
* * * * VHM.Activate
* * * * Cancel = True
End Sub

Thanks for any help you can offer.

Michael


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Macro that opens a separate workbook to a specified worksheetwhen the active workbook is right mouse clicked

Don

I must be missing something still. The Workbooks.Open... line
debugged. I arrangend your macro as follows:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
Workbooks.Open(Filename:="C:\Documents\E-Z Vocal Help Menu.xls",
UpdateLinks:=3).RunAutoMacros Which:=xlAutoOpen
Sheets("Wizard").Select
Range("A1").Select
End Sub

Do you see where I went wrong? Many thanks.

Michael
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro that opens a separate workbook to a specified worksheet when the active workbook is right mouse clicked

It happens that Michael Lanier formulated :
UpdateLinks:=3).RunAutoMacros Which:=xlAutoOpen


Change the above to...

UpdateLinks:=3, RunAutoMacros Which:=xlAutoOpen

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro that opens a separate workbook to a specified worksheet when the active workbook is right mouse clicked

Oops! Should have waited until after my 1st coffee...

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)
Workbooks.Open _
Filename:="C:\Documents\E-Z Vocal Help Menu.xls", UpdateLinks:=3
Application.RunAutoMacros Which:=xlAutoOpen
Sheets("Wizard").Select: Range("A1").Select
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Macro that opens a separate workbook to a specified worksheetwhen the active workbook is right mouse clicked

Garry

Unfortunately, yours and Don's suggestions still debug, which may well
be something I'm doing. I have been able to get my initial macro to
work which was due to a path problem in my string text in
Worksheets("DataBase").Range("M373"). However, I could very much use
any suggestions you might have that would allow me to jump to a
designated sheet when the file is opened. Everything I've tried fails
to execute once the file is opened. Regardless, thanks for your
suggestions.

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
Dim VHM As Workbook
Set VHM = ActiveWorkbook
Dim exlApp As Excel.Application
Set exlApp = New Excel.Application
exlApp.Visible = True
exlApp.Workbooks.Open Worksheets("DataBase").Range("M373")
VHM.Activate
Cancel = True
End Sub

Michael
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
Macro to copy active worksheet to new workbook Macca Excel Discussion (Misc queries) 1 May 25th 08 02:07 PM
When I open a workbook, how can I choose which worksheet opens? josephdmcc Excel Worksheet Functions 1 April 12th 06 04:59 PM
Issuing macro in workbook from separate workbook Nigel Excel Discussion (Misc queries) 1 May 16th 05 05:46 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM


All times are GMT +1. The time now is 12:49 PM.

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

About Us

"It's about Microsoft Excel"