Determine type of workbook

stuartgb100

Active Member
Joined
May 10, 2015
Messages
287
Office Version
  1. 2021
Platform
  1. Windows
Hi,

What is the best way to establish the type of workbook that has opened
(eg template, macro-enabled etc) ?

This is in Excel 2010.

Thanks.
 
Help, please !

I opened Excel, and saved the new workbook as a template (Test Template).

I then opened the template (Test Template 1).

In the immediate window I typed:
debug.Print activeworkbook.FileFormat

and the answer: 52

In the open template I added a module and placed Joe4's Select Case code,
then ran it,

and the answer: Something Else.

?????

Thanks.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Did you see shg's comments?
That might be what is happening.
 
Upvote 0
So, It's a file that is not recognised as having been previously saved.

A couple of workarounds ?

1. Create a hidden sheet in the original template and place
"Template Workbook" in cell "A1".
When the template opens, user is forced to save as a .xlsm workbook,
then remove the value "Template Workbook" before the save.

2. Remove all code relevant to the Template workbook, before the save
to an xlsm workbook.

Is there really no way to establish if the opened workbook comes from a template ?

Regards and thanks.
 
Upvote 0
It's a file that is not recognised as having been previously saved.
It hasn't been saved -- that's why it has no extension.
Is there really no way to establish if the opened workbook comes from a template ?
There isn't. You could put some value in a cell or name, and test that on opening as a hack.
 
Upvote 0
Another (wild) thought:

Could I do something like ...

If file not saved = true ???

Regards.
 
Upvote 0
Code:
if len(activeworkbook.path) = 0 then
   ' it hasn't been saved
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,933
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top