ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error when running macro from another workbook (https://www.excelbanter.com/excel-programming/430180-error-when-running-macro-another-workbook.html)

Scooter

error when running macro from another workbook
 

With the below code in a workbook I get "Cannot run macro. Macro may not be
available in this workbook or all macros my be disabled." I have checked
that all macros are enabled under the trust center and MonthlyUpdate is not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub



Eduardo

error when running macro from another workbook
 

Hi,
Was the workbook saved with extension xlsm (macro enable)

"Scooter" wrote:

With the below code in a workbook I get "Cannot run macro. Macro may not be
available in this workbook or all macros my be disabled." I have checked
that all macros are enabled under the trust center and MonthlyUpdate is not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub



Patrick Molloy

error when running macro from another workbook
 

it may not help but i changed your code

check the excel security levels

Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")

File2Update.Save
File2Update.Close

End Sub


"Scooter" wrote in message
...
With the below code in a workbook I get "Cannot run macro. Macro may not
be
available in this workbook or all macros my be disabled." I have
checked
that all macros are enabled under the trust center and MonthlyUpdate is
not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub



Scooter

error when running macro from another workbook
 

Even though I am running Office 2007 both workbooks have the .xls extension.


"Eduardo" wrote:

Hi,
Was the workbook saved with extension xlsm (macro enable)

"Scooter" wrote:

With the below code in a workbook I get "Cannot run macro. Macro may not be
available in this workbook or all macros my be disabled." I have checked
that all macros are enabled under the trust center and MonthlyUpdate is not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub



Patrick Molloy

error when running macro from another workbook
 

actually, i didn't change your code where it matters :(
it looks fine & should work...hence the comment on security levels

"Patrick Molloy" wrote in message
...
it may not help but i changed your code

check the excel security levels

Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")

File2Update.Save
File2Update.Close

End Sub


"Scooter" wrote in message
...
With the below code in a workbook I get "Cannot run macro. Macro may not
be
available in this workbook or all macros my be disabled." I have
checked
that all macros are enabled under the trust center and MonthlyUpdate is
not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub



Scooter

error when running macro from another workbook
 

The code is erroring on the line - MyResult =
Application.Run(File2Update.Name & "!MonthlyUpdate"). I think your changes
were after that.

The security setting is - Enable all macros (not recommended,
potentially dangerous code can run)

"Patrick Molloy" wrote:

it may not help but i changed your code

check the excel security levels

Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")

File2Update.Save
File2Update.Close

End Sub


"Scooter" wrote in message
...
With the below code in a workbook I get "Cannot run macro. Macro may not
be
available in this workbook or all macros my be disabled." I have
checked
that all macros are enabled under the trust center and MonthlyUpdate is
not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub




Patrick Molloy

error when running macro from another workbook
 

excel 2003?

"Scooter" wrote in message
...
The code is erroring on the line - MyResult =
Application.Run(File2Update.Name & "!MonthlyUpdate"). I think your
changes
were after that.

The security setting is - Enable all macros (not recommended,
potentially dangerous code can run)

"Patrick Molloy" wrote:

it may not help but i changed your code

check the excel security levels

Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")

File2Update.Save
File2Update.Close

End Sub


"Scooter" wrote in message
...
With the below code in a workbook I get "Cannot run macro. Macro may
not
be
available in this workbook or all macros my be disabled." I have
checked
that all macros are enabled under the trust center and MonthlyUpdate is
not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub




Scooter

error when running macro from another workbook
 

I am running Office 2007 and both workbooks have the .xls extension.


"Patrick Molloy" wrote:

excel 2003?

"Scooter" wrote in message
...
The code is erroring on the line - MyResult =
Application.Run(File2Update.Name & "!MonthlyUpdate"). I think your
changes
were after that.

The security setting is - Enable all macros (not recommended,
potentially dangerous code can run)

"Patrick Molloy" wrote:

it may not help but i changed your code

check the excel security levels

Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")

File2Update.Save
File2Update.Close

End Sub


"Scooter" wrote in message
...
With the below code in a workbook I get "Cannot run macro. Macro may
not
be
available in this workbook or all macros my be disabled." I have
checked
that all macros are enabled under the trust center and MonthlyUpdate is
not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub





Eduardo

error when running macro from another workbook
 

Hi,
when opening the file you have to say yes to that message, better if you go
and save as the file and then choose extension xlsm (enable macros)

"Scooter" wrote:

I am running Office 2007 and both workbooks have the .xls extension.


"Patrick Molloy" wrote:

excel 2003?

"Scooter" wrote in message
...
The code is erroring on the line - MyResult =
Application.Run(File2Update.Name & "!MonthlyUpdate"). I think your
changes
were after that.

The security setting is - Enable all macros (not recommended,
potentially dangerous code can run)

"Patrick Molloy" wrote:

it may not help but i changed your code

check the excel security levels

Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")

File2Update.Save
File2Update.Close

End Sub


"Scooter" wrote in message
...
With the below code in a workbook I get "Cannot run macro. Macro may
not
be
available in this workbook or all macros my be disabled." I have
checked
that all macros are enabled under the trust center and MonthlyUpdate is
not a
private sub and does exist in the second workbook. What am I missing?


Sub UpdateBig()

Dim PathToFile As String
Dim File2Update As Workbook
Dim MyResult As Variant
Dim NameofFile As String

NameofFile = "abc.xls"
PathToFile = "C:\Documents and Settings\me\My Documents"
Set File2Update = Workbooks.Open(PathToFile & "\" & NameofFile)
MyResult = Application.Run(File2Update.Name & "!MonthlyUpdate")
Windows(File2Update).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com