ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How come my macro works if I pause and play again? (https://www.excelbanter.com/excel-programming/292629-how-come-my-macro-works-if-i-pause-play-again.html)

Kenji[_3_]

How come my macro works if I pause and play again?
 
I have this code

----
ThisWorkbook.SaveCopyAs Application.DefaultFilePath + "\" + "temp.xls"
----

When I run the macro from the front page, it'll give an, "Method
'SaveCopyAs' of object '_Workbook' failed.
however, if I click debug and hit "play" again, the code will go through
just fine. Is there a fix for this?

Kenji



Nick Cranham

How come my macro works if I pause and play again?
 
Kenji,
What's the value of "Application.DefaultFilePath" ?

NickHK

"Kenji" wrote in message
...
I have this code

----
ThisWorkbook.SaveCopyAs Application.DefaultFilePath + "\" + "temp.xls"
----

When I run the macro from the front page, it'll give an, "Method
'SaveCopyAs' of object '_Workbook' failed.
however, if I click debug and hit "play" again, the code will go through
just fine. Is there a fix for this?

Kenji





Bob Phillips[_6_]

How come my macro works if I pause and play again?
 
See my response in .Misc.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Kenji" wrote in message
...
I have this code

----
ThisWorkbook.SaveCopyAs Application.DefaultFilePath + "\" + "temp.xls"
----

When I run the macro from the front page, it'll give an, "Method
'SaveCopyAs' of object '_Workbook' failed.
however, if I click debug and hit "play" again, the code will go through
just fine. Is there a fix for this?

Kenji





Tushar Mehta

How come my macro works if I pause and play again?
 
When and how is the code executed? Is it part of an event procedure?

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , kenji4861
@burningmail.com says...
I have this code

----
ThisWorkbook.SaveCopyAs Application.DefaultFilePath + "\" + "temp.xls"
----

When I run the macro from the front page, it'll give an, "Method
'SaveCopyAs' of object '_Workbook' failed.
however, if I click debug and hit "play" again, the code will go through
just fine. Is there a fix for this?

Kenji





All times are GMT +1. The time now is 02:24 AM.

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