A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Running Macros



 
 
Thread Tools Display Modes
  #1  
Old July 6th, 2006, 03:44 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Running Macros

I have the following Macro (which I need to run on approximately 200
different workbooks) -- what is the BEST way to achieve this? Should I use
a Function (and if so, what would it look like)?

NOTE: I'm assuming that this Macro should reside in a Module -- but, should
this be run outside of EXCEL (say, from a Form in ACCESS)?

Here's my code:

Does anyone see anything that I may be missing? Here's the MOST important
thing I need this code to do (assuming there are no further modifications
needed) ...



This code (Macro) needs to perform this same task on approximately 200
different Workbooks (all residing in the same Network Directory), but ONLY
when a Command Button is pressed. I'm assuming that I'll need to create a
Form (in ACCESS perhaps) and call this Macro -- correct? How would I do
this, and how would I get this Macro to perform this Link Update on all 200
or so Workbooks?



Private Sub Workbook_Open()
Dim vLinkSources
Dim iLinkSource As Integer
Dim AnySheet As Worksheet
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Unprotect
Password:="mypassword"
Next
vLinkSources = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(vLinkSources) Then
For iLinkSource = LBound(vLinkSources) To
UBound(vLinkSources)
ActiveWorkbook.UpdateLink vLinkSources(iLinkSource), xlExcelLinks
Next
End If
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Protect
Password:="mypassword"
Next
End Sub


  #2  
Old July 7th, 2006, 05:24 AM posted to microsoft.public.access.forms
Larry Linson
external usenet poster
 
Posts: 3,112
Default Running Macros

If the functionality you need is in Excel, then you'd only be complicating
the matter by trying to run it via COM Automation from Access. I admit that
I have not implemented any Excel applications using VBA and the Excel Object
Model, but I'm sure you can accomplish what you want completely in Excel.

As the Excel Object Model and other details are significantly different from
Access, I'd suggest the best place to ask would be in an Excel newsgroup,
particularly one that deals with VBA code (aka, but not quite correctly,
also referred to as "macros" in the Excel environment) in Excel.

My recollection is that you can use Microsoft Forms to create the Forms that
you'd use with Excel spreadsheets.

Larry Linson
Microsoft Access MVP



wrote in message
...
I have the following Macro (which I need to run on approximately 200
different workbooks) -- what is the BEST way to achieve this? Should I use
a Function (and if so, what would it look like)?

NOTE: I'm assuming that this Macro should reside in a Module -- but,
should this be run outside of EXCEL (say, from a Form in ACCESS)?

Here's my code:

Does anyone see anything that I may be missing? Here's the MOST important
thing I need this code to do (assuming there are no further modifications
needed) ...



This code (Macro) needs to perform this same task on approximately 200
different Workbooks (all residing in the same Network Directory), but ONLY
when a Command Button is pressed. I'm assuming that I'll need to create a
Form (in ACCESS perhaps) and call this Macro -- correct? How would I do
this, and how would I get this Macro to perform this Link Update on all
200 or so Workbooks?



Private Sub Workbook_Open()
Dim vLinkSources
Dim iLinkSource As Integer
Dim AnySheet As Worksheet
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Unprotect
Password:="mypassword"
Next
vLinkSources = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(vLinkSources) Then
For iLinkSource = LBound(vLinkSources) To
UBound(vLinkSources)
ActiveWorkbook.UpdateLink vLinkSources(iLinkSource), xlExcelLinks
Next
End If
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Protect
Password:="mypassword"
Next
End Sub




  #3  
Old July 10th, 2006, 07:02 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Running Macros

Thank you Larry -- I'll look into that and let you know how it turns out --
thanks for your advice and suggestion.
"Larry Linson" wrote in message
...
If the functionality you need is in Excel, then you'd only be complicating
the matter by trying to run it via COM Automation from Access. I admit
that I have not implemented any Excel applications using VBA and the Excel
Object Model, but I'm sure you can accomplish what you want completely in
Excel.

As the Excel Object Model and other details are significantly different
from Access, I'd suggest the best place to ask would be in an Excel
newsgroup, particularly one that deals with VBA code (aka, but not quite
correctly, also referred to as "macros" in the Excel environment) in
Excel.

My recollection is that you can use Microsoft Forms to create the Forms
that you'd use with Excel spreadsheets.

Larry Linson
Microsoft Access MVP



wrote in message
...
I have the following Macro (which I need to run on approximately 200
different workbooks) -- what is the BEST way to achieve this? Should I
use a Function (and if so, what would it look like)?

NOTE: I'm assuming that this Macro should reside in a Module -- but,
should this be run outside of EXCEL (say, from a Form in ACCESS)?

Here's my code:

Does anyone see anything that I may be missing? Here's the MOST
important thing I need this code to do (assuming there are no further
modifications needed) ...



This code (Macro) needs to perform this same task on approximately 200
different Workbooks (all residing in the same Network Directory), but
ONLY when a Command Button is pressed. I'm assuming that I'll need to
create a Form (in ACCESS perhaps) and call this Macro -- correct? How
would I do this, and how would I get this Macro to perform this Link
Update on all 200 or so Workbooks?



Private Sub Workbook_Open()
Dim vLinkSources
Dim iLinkSource As Integer
Dim AnySheet As Worksheet
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Unprotect
Password:="mypassword"
Next
vLinkSources = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(vLinkSources) Then
For iLinkSource = LBound(vLinkSources) To
UBound(vLinkSources)
ActiveWorkbook.UpdateLink vLinkSources(iLinkSource), xlExcelLinks
Next
End If
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Protect
Password:="mypassword"
Next
End Sub






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:55 AM.


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