ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Script for copy and paste to save (https://www.excelbanter.com/excel-discussion-misc-queries/26365-vba-script-copy-paste-save.html)

tamato43

VBA Script for copy and paste to save
 
I think I may be asking for too much.

I tried Recording a Macro for Saving the content on Cell A1(which is where I
previously enterd a name), then go to "file", then "Save as" and then try to
Paste In the "File Name" Window.

It doesn't seem to work.

Does anyone know how to swing this one?

Dave Peterson

You could embed that value directly in the code--you don't need to copy|paste
into the dialog:

Something like:

ActiveWorkbook.SaveAs Filename:=ActiveSheet.Range("a1").Value & ".xls", _
FileFormat:=xlWorkbookNormal



tamato43 wrote:

I think I may be asking for too much.

I tried Recording a Macro for Saving the content on Cell A1(which is where I
previously enterd a name), then go to "file", then "Save as" and then try to
Paste In the "File Name" Window.

It doesn't seem to work.

Does anyone know how to swing this one?


--

Dave Peterson

tamato43

Thank you very much,

Is it also possible to designate a folder?

"Dave Peterson" wrote:

You could embed that value directly in the code--you don't need to copy|paste
into the dialog:

Something like:

ActiveWorkbook.SaveAs Filename:=ActiveSheet.Range("a1").Value & ".xls", _
FileFormat:=xlWorkbookNormal



tamato43 wrote:

I think I may be asking for too much.

I tried Recording a Macro for Saving the content on Cell A1(which is where I
previously enterd a name), then go to "file", then "Save as" and then try to
Paste In the "File Name" Window.

It doesn't seem to work.

Does anyone know how to swing this one?


--

Dave Peterson


Dave Peterson

Su

dim myFolder as string
myfolder = "C:\my documents\excel\"

ActiveWorkbook.SaveAs Filename:=myfolder & _
ActiveSheet.Range("a1").Value & ".xls", FileFormat:=xlWorkbookNormal



tamato43 wrote:

Thank you very much,

Is it also possible to designate a folder?

"Dave Peterson" wrote:

You could embed that value directly in the code--you don't need to copy|paste
into the dialog:

Something like:

ActiveWorkbook.SaveAs Filename:=ActiveSheet.Range("a1").Value & ".xls", _
FileFormat:=xlWorkbookNormal



tamato43 wrote:

I think I may be asking for too much.

I tried Recording a Macro for Saving the content on Cell A1(which is where I
previously enterd a name), then go to "file", then "Save as" and then try to
Paste In the "File Name" Window.

It doesn't seem to work.

Does anyone know how to swing this one?


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 09:46 PM.

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