Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default forcing specific sheet opening upon launch of .xlsx file

Need some help....

I have a simple macro running on Win7/Excel 2007 that inserts different versions of legal disclaimers as the first tab of a target workbook.

The macro is in a separate macro-enabled file due to detailed instructions that the user must read before launching the form that guides the user into selecting the correct disclaimer for insertion on the first tab of the target workbook.

I've been asked to ensure that when the completed target file is opened, the legal disclaimer page is always the first sheet visible. However, the target file must be saved in a .xlsx, not .xlsm format.

Any suggestions on how to affect this type action without embedding VBA code within the target workbook?

Art
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default forcing specific sheet opening upon launch of .xlsx file

Hi Art,

The following macros should work. Basically, it will take the target workbook file path and name and check to see if it is open. If not, it will open the workbook. Next, it will look for a sheet called "Disclaimer" and move it to the front of the workbook. You can adjust this macro to fit your needs. For example, you could link the file path and/or workbook name to cells in your macro workbook.
Hope this helps,
Ben

Sub MoveSheet()
Dim sWB As String 'Workbook Name with extension
Dim sFP As String 'Filepath
Dim WB As Workbook 'Workbook

sWB = "MyWorkbook.xlsx" 'Range("A1")
sFP = "C:\Desktop\" 'Range("A2")

If BookOpen(sWB) = False Then _
Workbooks.Open sFP & sWB, False, False
Set WB = Workbooks(sWB)
WB.Sheets("Disclaimer").Move Befo=WB.Sheets(1)

End Sub

Function BookOpen(WBk As String) As Boolean
'Checks whether a workbook is open

BookOpen = False

On Error GoTo NotOpen
Application.DisplayAlerts = False

Workbooks(WBk).Activate
BookOpen = True

NotOpen:
Err.Clear
End Function
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default forcing specific sheet opening upon launch of .xlsx file

Ben,

thanks for the response. However, my code works as advertised. What I was asked to make happen is ensuring that anyone who opens up the target file once my macro has updated it will always see the first 'disclaimer' sheet regardless of what state they left the workbook in during their previous session - and the workbook can't have embedded code in it.

Is there any way to set a specific sheet to the opening view in Excel as the default?

Art


On Monday, September 24, 2012 5:19:45 PM UTC-4, Ben McClave wrote:
Hi Art,



The following macros should work. Basically, it will take the target workbook file path and name and check to see if it is open. If not, it will open the workbook. Next, it will look for a sheet called "Disclaimer" and move it to the front of the workbook. You can adjust this macro to fit your needs. For example, you could link the file path and/or workbook name to cells in your macro workbook.

Hope this helps,

Ben



Sub MoveSheet()

Dim sWB As String 'Workbook Name with extension

Dim sFP As String 'Filepath

Dim WB As Workbook 'Workbook



sWB = "MyWorkbook.xlsx" 'Range("A1")

sFP = "C:\Desktop\" 'Range("A2")



If BookOpen(sWB) = False Then _

Workbooks.Open sFP & sWB, False, False

Set WB = Workbooks(sWB)

WB.Sheets("Disclaimer").Move Befo=WB.Sheets(1)



End Sub



Function BookOpen(WBk As String) As Boolean

'Checks whether a workbook is open



BookOpen = False



On Error GoTo NotOpen

Application.DisplayAlerts = False



Workbooks(WBk).Activate

BookOpen = True



NotOpen:

Err.Clear

End Function


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default forcing specific sheet opening upon launch of .xlsx file

Ben,

thanks for the guidance - I'll try your suggestions in a few days when I'm back at my workstation

Art


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
How do I set default Excel Saveas file format to xlsx not xlsx Greg Conway Setting up and Configuration of Excel 1 September 17th 08 04:19 PM
opening text file as a .xls file and not a .xlsx Russ Excel Programming 4 June 8th 08 06:43 PM
Problem opening an.xls or xlsx file Dr. Dos New Users to Excel 2 December 7th 07 09:59 PM
Opening a XLSX File from 2007 excel to 2003 excel lvasquez3 Excel Discussion (Misc queries) 0 July 2nd 07 03:50 PM
Launch a VBA macro with opening a file LOLO53 Excel Programming 2 December 5th 04 10:29 PM


All times are GMT +1. The time now is 03:12 AM.

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"