Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combining Macros to make one Macro.

I have several workbooks, each has many formulas which get data from on
other workbook.

Example: Workbook #1 gets data from workbook 1a.
Workbook #2 gets data from workbook 2a.
Workbook #3 gets data from workbook 3a.
Workbook #4 gets data from workbook 4a.
Workbook #5 gets data from workbook 5a.

The "a" workbooks are created with data automatically by an expor
function from Access 97.

I have created a macro for each workbook which unshares, unprotects
breaks links, and resaves the workbook.

These macros are all saved in my personal.xls file.

Each macro uses a different ctrl+shift+letter shortcut key to run. I
is really inconvenient to try to remember which shortcut key goes wit
the particular form I am using at the time.

What I would like to do is to somehow combine these macros into jus
one macro which will check to see which form I have open and then ru
the appropriate instructions while only using one shortcut key.

Below is the VBA of each macro:

Sub UndoLinksDataInput()
'
' UndoLinksDataInput Macro
' Macro recorded 6/25/2004 by B80671
'
' Keyboard Shortcut: Ctrl+l
'
ActiveWorkbook.ExclusiveAccess
ActiveSheet.Unprotect
ActiveWorkbook.BreakLink Name:="C:\BBTDATA\Data Input.xls", Type:
_
xlExcelLinks
ActiveWorkbook.Save
End Sub


Sub UndoLinksBNumber()
'
' UndoLinksBNumber Macro
' Macro recorded 6/25/2004 by B80671
'
' Keyboard Shortcut: Ctrl+m
'
ActiveWorkbook.ExclusiveAccess
ActiveSheet.Unprotect
ActiveWorkbook.BreakLink Name:="C:\BBTDATA\Search by B Number.xls"
Type:= _
xlExcelLinks
ActiveWorkbook.Save
End Sub


Sub UndoLinkSerialNumber()
'
' UndoLinkSerialNumber Macro
' Macro recorded 6/25/2004 by B80671
'
' Keyboard Shortcut: Ctrl+n
'
ActiveWorkbook.ExclusiveAccess
ActiveSheet.Unprotect
ActiveWorkbook.BreakLink Name:="C:\BBTDATA\Search by Seria
Number.xls", _
Type:=xlExcelLinks
ActiveWorkbook.Save
End Sub


Sub UndoLinkUsersName()
'
' UndoLinkUsersName Macro
' Macro recorded 6/25/2004 by B80671
'
' Keyboard Shortcut: Ctrl+o
'
ActiveWorkbook.ExclusiveAccess
ActiveSheet.Unprotect
ActiveWorkbook.BreakLink Name:="C:\BBTDATA\Search by User
Name.xls", Type _
:=xlExcelLinks
ActiveWorkbook.Save
End Sub


Sub UndoLinksDate()
'
' UndoLinksDate Macro
' Macro recorded 7/8/2004 by B80671
'
' Keyboard Shortcut: Ctrl+t
'
ActiveWorkbook.ExclusiveAccess
ActiveSheet.Unprotect
ActiveWorkbook.BreakLink Name:="C:\BBTDATA\Search by Dat
Form.xls", Type _
:=xlExcelLinks
ActiveWorkbook.Save
End Sub


Also, when the ActiveWorkbook.ExclusiveAcces occurs, it asks fo
confirmation. If there were a way to automatically tell it yes, so i
would not pause at that point, that would be great.

This has been torturing me for quite some time now. Any help would b
greatly appreciated.

Jess

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Combining Macros to make one Macro.

The macros only vary by the name of the linked file. Assuming they all have
just one linked file you can break it by position rather than by name:

ActiveWorkbook.BreakLink _
ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLi nks)(1), _
xlLinkTypeExcelLinks

So you only need one macro.

Use this to block the prompt:

Application.DisplayAlerts = False
ActiveWorkbook.ExclusiveAccess

--
Jim Rech
Excel MVP


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
Combining two macros Colin Hayes Excel Discussion (Misc queries) 2 June 7th 11 02:28 PM
Combining macros aussiegirlone Excel Discussion (Misc queries) 9 June 30th 09 03:14 AM
make macro run other macros in Exc 2007,no problems in Exc 2003 SteveB Excel Discussion (Misc queries) 2 October 19th 08 02:30 AM
make macros usable! make instructions in plain english !!!! Brainless_in_Boston Excel Worksheet Functions 0 March 2nd 06 03:27 PM
Combining 3 macros to 1 David Excel Programming 3 April 16th 04 02:35 PM


All times are GMT +1. The time now is 09:32 AM.

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"