ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.Run problem. (https://www.excelbanter.com/excel-programming/350292-application-run-problem.html)

Chip[_3_]

Application.Run problem.
 
I tried reading on this group and others about using Application.Run.
Basically, I am trying to have one workbook run a macro that is in
another workbook. I can get the "Master" workbook to call the macro in
the other workbook, but when the code is finished I want it to finish
running the code back in the Master Workbook (like a normal call
would). Is there a way to do this?

Here is my code from the "Slave" workbook:



Public Sub Saveaftereview()
If IsEmpty(Range("A25").Value) Then
Dim startingname As String
startingname = "Position Control-" & Range("A50").Value & "-" &
Range("B50").Value & "-" & Range("C50").Value & ".xls"
Dim myFileName As Variant
myFileName = Application.GetSaveAsFilename _
(InitialFileName:="c:\" & startingname)

Else

myFileName = Range("A25").Value
End If

If myFileName = False Then
'user hit cancel
Else
Sheets("Save Page").Visible = False

Sheets("Travelers Worksheet").Select
ActiveSheet.Buttons(1).Select
selection.OnAction = "Addworksheet"
Range("A7").Select



'Added as of January 10th 2006
Sheets("LOA Worksheet").Select
ActiveSheet.Shapes("Button 1").Select
selection.OnAction = "Addworksheet"
Range("A4").Select
Sheets("Job Postings Worksheet").Select
ActiveSheet.Shapes("Button 1").Select
selection.OnAction = "Addworksheet"


Range("A4").Select


Sheets("Position Control").Select
Call protector
Range("A13").Select
ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlNormal
ActiveWorkbook.Close

End If


End Sub


In the Master it reads something like Application.Run (Name of the
file)!Saveafterreview


Any thoughts?


Bob Phillips[_6_]

Application.Run problem.
 
Aren't you closing the book with the code in it, thereby effectively
aborting the code?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Chip" wrote in message
ups.com...
I tried reading on this group and others about using Application.Run.
Basically, I am trying to have one workbook run a macro that is in
another workbook. I can get the "Master" workbook to call the macro in
the other workbook, but when the code is finished I want it to finish
running the code back in the Master Workbook (like a normal call
would). Is there a way to do this?

Here is my code from the "Slave" workbook:



Public Sub Saveaftereview()
If IsEmpty(Range("A25").Value) Then
Dim startingname As String
startingname = "Position Control-" & Range("A50").Value & "-" &
Range("B50").Value & "-" & Range("C50").Value & ".xls"
Dim myFileName As Variant
myFileName = Application.GetSaveAsFilename _
(InitialFileName:="c:\" & startingname)

Else

myFileName = Range("A25").Value
End If

If myFileName = False Then
'user hit cancel
Else
Sheets("Save Page").Visible = False

Sheets("Travelers Worksheet").Select
ActiveSheet.Buttons(1).Select
selection.OnAction = "Addworksheet"
Range("A7").Select



'Added as of January 10th 2006
Sheets("LOA Worksheet").Select
ActiveSheet.Shapes("Button 1").Select
selection.OnAction = "Addworksheet"
Range("A4").Select
Sheets("Job Postings Worksheet").Select
ActiveSheet.Shapes("Button 1").Select
selection.OnAction = "Addworksheet"


Range("A4").Select


Sheets("Position Control").Select
Call protector
Range("A13").Select
ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlNormal
ActiveWorkbook.Close

End If


End Sub


In the Master it reads something like Application.Run (Name of the
file)!Saveafterreview


Any thoughts?




Chip[_3_]

Application.Run problem.
 
Yes, yes I am. I sware I tried the code without that in it and still
had the same problem, but I messed with the code and it works now.
Thanks!



All times are GMT +1. The time now is 05:49 PM.

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