Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problems with user created command bar

I have a command bar that is created when the workbook is open. I need
to hide/unhide a few columns based on what the user selects. I use the
function below to do hide/unhide the columns. ProjectPlan refers to the
code name of the worksheet that I need to hide/unhide the columns for.


Public Sub ShowHide(RangeName As String, Show As Boolean)
'**** Function for showhiding ****
projectPlan.Range(RangeName).EntireColumn.Hidden = Not Show
If Show Then

projectPlan.Sheets("Project Plan").Range(RangeName).Cells(1, 1).Select
End If
End Sub

I am running into problems when there are 2 workbooks open. The VBA
code name for the worksheet is being resolved to the most recently
opened workbook (activework.name and projectplan.parent.name do not
match). Is there a way of making the commandbar realize that it has to
resolve the name to the activeworkbook and not the most recently opened
workbook. I do not want to use the sheet names in order to reference
the worksheet.

Thanks,
Naveen

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Problems with user created command bar

Worksheet codenames are not intended to be use from outside their VB
projects. As far as I know, in order to do so you have to jump through
hoops like this:

Sub UsedCodeNameFromOutsideProject()
Dim WS As Worksheet
With ActiveWorkbook
Set WS =
..Worksheets(CStr(.VBProject.VBComponents("MyCoden ameForSheet").Properties(7)))
MsgBox WS.Name
End With
End Sub


--
Jim
wrote in message
ups.com...
|I have a command bar that is created when the workbook is open. I need
| to hide/unhide a few columns based on what the user selects. I use the
| function below to do hide/unhide the columns. ProjectPlan refers to the
| code name of the worksheet that I need to hide/unhide the columns for.
|
|
| Public Sub ShowHide(RangeName As String, Show As Boolean)
| '**** Function for showhiding ****
| projectPlan.Range(RangeName).EntireColumn.Hidden = Not Show
| If Show Then
|
| projectPlan.Sheets("Project Plan").Range(RangeName).Cells(1, 1).Select
| End If
| End Sub
|
| I am running into problems when there are 2 workbooks open. The VBA
| code name for the worksheet is being resolved to the most recently
| opened workbook (activework.name and projectplan.parent.name do not
| match). Is there a way of making the commandbar realize that it has to
| resolve the name to the activeworkbook and not the most recently opened
| workbook. I do not want to use the sheet names in order to reference
| the worksheet.
|
| Thanks,
| Naveen
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problems with user created command bar

Thanks Jim !

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
Problems with IRM protected files created before 18/11/09 gwaxiom Excel Discussion (Misc queries) 0 November 21st 09 09:30 PM
I've created an Excel worksheet using the Vlookup command. LionHearted1952 Excel Worksheet Functions 1 May 8th 08 10:53 PM
export from Access to Excel has created problems with Siuan New Users to Excel 3 July 19th 06 01:05 AM
PC-created files used on a Mac - Problems JEFF Excel Discussion (Misc queries) 4 July 29th 05 09:26 PM
How do I assign a macro I have created to a Command Button in Exc. Andrew7675 Excel Discussion (Misc queries) 1 March 3rd 05 08:08 PM


All times are GMT +1. The time now is 11:06 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"