ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Name Increment on Open (https://www.excelbanter.com/excel-programming/392984-name-increment-open.html)

T Kirtley

Name Increment on Open
 
I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK



Bob Phillips

Name Increment on Open
 
Do you have workbook beforeclose or beforesave code that is changing the
name? look in ThisWorkbook code module.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"T Kirtley" wrote in message
...
I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When
the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if
it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a
wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with
its
original name.

TIA for any help,

TK





Dave Peterson

Name Increment on Open
 
What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK


--

Dave Peterson

T Kirtley

Name Increment on Open
 
Thanks for the reply. I don't recall any BeforeClose or BeforeSave events,
but the code was written a year ago and I may be forgetting something...
I'll check tomorrow.

"Bob Phillips" wrote:

Do you have workbook beforeclose or beforesave code that is changing the
name? look in ThisWorkbook code module.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"T Kirtley" wrote in message
...
I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When
the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if
it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a
wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with
its
original name.

TIA for any help,

TK






T Kirtley

Name Increment on Open
 
Thanks for the reply. The workbook is an xls file, and it behaves as expected
when opened manually, but when opened with vba it is acting just like a
template. Funny thing is this was initially used as a template a year ago but
the users wanted to work with it as a workbook so it was changed to an xls
file. Could the one-time use as a template still be stored in some property?

TK

"Dave Peterson" wrote:

What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK


--

Dave Peterson


Dave Peterson

Name Increment on Open
 
I saved a workbook as a template, but with a .xls extension (I could have
renamed that file from *.xls to *.xlt) and excel was smart enough to use it as a
template file.

I'd open that workbook and do a file|SaveAs and make sure it was saved as a
Normal workbook. Then test that out.

T Kirtley wrote:

Thanks for the reply. The workbook is an xls file, and it behaves as expected
when opened manually, but when opened with vba it is acting just like a
template. Funny thing is this was initially used as a template a year ago but
the users wanted to work with it as a workbook so it was changed to an xls
file. Could the one-time use as a template still be stored in some property?

TK

"Dave Peterson" wrote:

What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK


--

Dave Peterson


--

Dave Peterson

Dave Peterson

Name Increment on Open
 
I meant that I could have saved the file as a template (*.xlt), then renamed it
to *.xls.

I reversed my extensions.

Dave Peterson wrote:

I saved a workbook as a template, but with a .xls extension (I could have
renamed that file from *.xls to *.xlt) and excel was smart enough to use it as a
template file.

I'd open that workbook and do a file|SaveAs and make sure it was saved as a
Normal workbook. Then test that out.

T Kirtley wrote:

Thanks for the reply. The workbook is an xls file, and it behaves as expected
when opened manually, but when opened with vba it is acting just like a
template. Funny thing is this was initially used as a template a year ago but
the users wanted to work with it as a workbook so it was changed to an xls
file. Could the one-time use as a template still be stored in some property?

TK

"Dave Peterson" wrote:

What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

T Kirtley

Name Increment on Open
 
I'm pretty sure you are right that the file extension was just changed to
xls, and that it was not 'saved as' a workbook, at least not when initally
changed from a template filetype... but I never thought there was anything to
a template except the xlt extension.

But I could believe that some hidden 'templatesque' property could remain
intact unless 'saved as' a workbook again, but it is confusing that the
workbook does open without name increment numbers when it is opened manually,
either through the file menu or double-clicking in Windows.

In any case this is definitely food for thought, and thanks for the
suggestion. I'll give it a go tomorrow and see if saving as a workbook puts
things right.

Thanks,

TK

"Dave Peterson" wrote:

I meant that I could have saved the file as a template (*.xlt), then renamed it
to *.xls.

I reversed my extensions.

Dave Peterson wrote:

I saved a workbook as a template, but with a .xls extension (I could have
renamed that file from *.xls to *.xlt) and excel was smart enough to use it as a
template file.

I'd open that workbook and do a file|SaveAs and make sure it was saved as a
Normal workbook. Then test that out.

T Kirtley wrote:

Thanks for the reply. The workbook is an xls file, and it behaves as expected
when opened manually, but when opened with vba it is acting just like a
template. Funny thing is this was initially used as a template a year ago but
the users wanted to work with it as a workbook so it was changed to an xls
file. Could the one-time use as a template still be stored in some property?

TK

"Dave Peterson" wrote:

What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


Dave Peterson

Name Increment on Open
 
Please post back when you have your results.

I'm curious to know what you found out.

T Kirtley wrote:

I'm pretty sure you are right that the file extension was just changed to
xls, and that it was not 'saved as' a workbook, at least not when initally
changed from a template filetype... but I never thought there was anything to
a template except the xlt extension.

But I could believe that some hidden 'templatesque' property could remain
intact unless 'saved as' a workbook again, but it is confusing that the
workbook does open without name increment numbers when it is opened manually,
either through the file menu or double-clicking in Windows.

In any case this is definitely food for thought, and thanks for the
suggestion. I'll give it a go tomorrow and see if saving as a workbook puts
things right.

Thanks,

TK

"Dave Peterson" wrote:

I meant that I could have saved the file as a template (*.xlt), then renamed it
to *.xls.

I reversed my extensions.

Dave Peterson wrote:

I saved a workbook as a template, but with a .xls extension (I could have
renamed that file from *.xls to *.xlt) and excel was smart enough to use it as a
template file.

I'd open that workbook and do a file|SaveAs and make sure it was saved as a
Normal workbook. Then test that out.

T Kirtley wrote:

Thanks for the reply. The workbook is an xls file, and it behaves as expected
when opened manually, but when opened with vba it is acting just like a
template. Funny thing is this was initially used as a template a year ago but
the users wanted to work with it as a workbook so it was changed to an xls
file. Could the one-time use as a template still be stored in some property?

TK

"Dave Peterson" wrote:

What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

T Kirtley

Name Increment on Open
 
That was it. When I selected 'save as' from the file menu the default format
was still a template. After saving as a workbook the code works fine. Problem
solved.

Thanks alot,

TK

"Dave Peterson" wrote:

Please post back when you have your results.

I'm curious to know what you found out.

T Kirtley wrote:

I'm pretty sure you are right that the file extension was just changed to
xls, and that it was not 'saved as' a workbook, at least not when initally
changed from a template filetype... but I never thought there was anything to
a template except the xlt extension.

But I could believe that some hidden 'templatesque' property could remain
intact unless 'saved as' a workbook again, but it is confusing that the
workbook does open without name increment numbers when it is opened manually,
either through the file menu or double-clicking in Windows.

In any case this is definitely food for thought, and thanks for the
suggestion. I'll give it a go tomorrow and see if saving as a workbook puts
things right.

Thanks,

TK

"Dave Peterson" wrote:

I meant that I could have saved the file as a template (*.xlt), then renamed it
to *.xls.

I reversed my extensions.

Dave Peterson wrote:

I saved a workbook as a template, but with a .xls extension (I could have
renamed that file from *.xls to *.xlt) and excel was smart enough to use it as a
template file.

I'd open that workbook and do a file|SaveAs and make sure it was saved as a
Normal workbook. Then test that out.

T Kirtley wrote:

Thanks for the reply. The workbook is an xls file, and it behaves as expected
when opened manually, but when opened with vba it is acting just like a
template. Funny thing is this was initially used as a template a year ago but
the users wanted to work with it as a workbook so it was changed to an xls
file. Could the one-time use as a template still be stored in some property?

TK

"Dave Peterson" wrote:

What's the name of the workbook that you're opening--it sounds like excel is
treating it as a template (*.xlt) workbook.

In fact, make sure that you didn't save the workbook (strFullFileName) as a
template with a .xls extension.

T Kirtley wrote:

I am opening a workbook using the following code:

Set wb = Workbooks.Open(strFullFileName, 0, False, , , , True)

where strFullFileName is the full path and filename of a workbook. When the
workbook opens, its name has an incremental suffix such as MyWorkbook12 if it
is the 12th time the MyWorkbook file was opened. Unfortunately, this
incremented name is what is used when the workbook is saved using a wb.save
statement, causing multiple copies of the workbook to be created.

What is causing this behavior? I suppose that there are cases where this
behavior was desirable, but I need to open and resave the workbook with its
original name.

TIA for any help,

TK

--

Dave Peterson


--

Dave Peterson

--

Dave Peterson


--

Dave Peterson


Dave Peterson

Name Increment on Open
 
Thanks for posting back.

T Kirtley wrote:

That was it. When I selected 'save as' from the file menu the default format
was still a template. After saving as a workbook the code works fine. Problem
solved.

Thanks alot,

TK

<<snipped


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

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