ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to add code to ThisWorkbook module (https://www.excelbanter.com/excel-programming/411912-macro-add-code-thisworkbook-module.html)

excelnut1954

Macro to add code to ThisWorkbook module
 
From an end of day macro, a sub performs a Save-As to creates a new
file name for the same data. Can I add code to the new file
ThisWorkbook module that will also perform a Save-As to create a third
file?

Ex: Macro in file First.xls performs Save-As to create file
Second.xls.
The same macro will add code in ThisWorkbook module of Second.xls that
will perform Save-As to create file named Third.xls.

Is this possible? I'm trying to do a work around that will free up the
file Second.xls when users open it up. This, so an end of day macro
can update Second.xls even if opens up that file before the report is
run.

Hope this makes sense.
Thanks
j.o.

Norman Jones[_2_]

Macro to add code to ThisWorkbook module
 
Hi ExcelNut,

See |Chip Pearson at::

Programming The VBA Editor
http://www.cpearson.com/excel/vbe.aspx





---
Regards.
Norman


"excelnut1954" wrote in message
...
From an end of day macro, a sub performs a Save-As to creates a new
file name for the same data. Can I add code to the new file
ThisWorkbook module that will also perform a Save-As to create a third
file?

Ex: Macro in file First.xls performs Save-As to create file
Second.xls.
The same macro will add code in ThisWorkbook module of Second.xls that
will perform Save-As to create file named Third.xls.

Is this possible? I'm trying to do a work around that will free up the
file Second.xls when users open it up. This, so an end of day macro
can update Second.xls even if opens up that file before the report is
run.

Hope this makes sense.
Thanks
j.o.



excelnut1954

Macro to add code to ThisWorkbook module
 
On Jun 2, 12:01*pm, "Norman Jones"
wrote:
Hi ExcelNut,

See |Chip Pearson at::

* * * * Programming The VBA Editor
* * * *http://www.cpearson.com/excel/vbe.aspx

---
Regards.
Norman

"excelnut1954" wrote in message

...



From an end of day macro, a sub performs a Save-As to creates a new
file name for the same data. Can I add code to the new file
ThisWorkbook module that will also perform a Save-As to create a third
file?


Ex: Macro in file First.xls performs Save-As to create file
Second.xls.
The same macro will add code in ThisWorkbook module of Second.xls that
will perform Save-As to create file named Third.xls.


Is this possible? I'm trying to do a work around that will free up the
file Second.xls when users open it up. This, so an end of day macro
can update Second.xls even if opens up that file before the report is
run.


Hope this makes sense.
Thanks
j.o.- Hide quoted text -


- Show quoted text -


Thanks, Norman.
I appreciate your reply. I went in Chip's site, and I think I found
what I needed. But, it looks like there are a few Excel settings that
would need to be changed in all the computers that would access this
file. That's impossible here. The settings on many programs in all the
computers here are all restored to default mode. Even Excel is
restored to default mode each night in all the computers. Really
sucks.

But, I found an old post that I adapted to help in a work around. It's
an If-then for the ThisWorkbook module. Very simple.

Sub fndFileNm()
fname = ActiveWorkbook.Name

Application.DisplayAlerts = False
If fname = "Current Furniture Staging List - testing.xls" Then
ActiveWorkbook.SaveAs _
Filename:="\\ceddfssrv01\cedroot\public\furniture staging list" &
"\Current Furniture Staging List - MacroTest.xls"
Application.DisplayAlerts = True

End If
End Sub

I tested it, and it seems to work. I'll try it in the live version of
the file tomorrow.



All times are GMT +1. The time now is 01:22 PM.

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