ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Order of open/close (https://www.excelbanter.com/excel-programming/308472-order-open-close.html)

Terry V

Order of open/close
 
Hello

I have a workbook that prompts a person to save the workbook. When the
workbook is saved, it is given a new name and then the original file
(template without xlt) is opened and the named file is closed.

In my code, I refer to Thisdocument.path and Activedocument.path.

Here's the problem. If I open the original document before closing the
saved on, it comes up with the filename of talktime1.xls instead of
Time.xls; because the original file is still in memory. So in my code where
I refer to Thisdocument.path and Activedocument.path, it is referring to
some temp folder on the machine.

How can I get by this and have the original document opened from its
original source? (Files folder where the Talktime.xls file is).
Thisworkbook.path says it is ""
Filename says "\Talktime1.xls" (after the file is opened)
Original filename is talktime.xls in the Files folder.
Saved filename should be Talk Time date -- time.xls (and it is) in the
Files\Results folder (and it is)

Seems to me that the saved file has to be closed first, but by doing that I
stop program execution.

thefilename = pth & "Talk Time" & " " & Tdate & " -- " & TTime
Application.ThisWorkbook.SaveAs (thefilename & " " & TTime & ".xls")


Workbooks.Open (wbp & "talktime.xls")
Workbooks(thefilename).Close savechanges:=False

Hope this makes sense to someone.

Thank you so much
Terry V




All times are GMT +1. The time now is 11:19 PM.

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