View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Object vs. New File in beforeSave event

Another one to consider subject to testing -

If the Name does not start with "Book" normally the file must have a path.
But seems if it's embedded "show as icon" it's name is not Book* and it
doesn't return a path.

bEmbedded = Left$(wb.Name,4) < "Book" and len(wb.path) = 0

Regards,
Peter T

"Peter T" <peter_t@discussions wrote in message
...
I think the difference between what we are doing is the "show as icon"

part.

Yes that explains the difference, .IsInPlace returns false when "show as
icon".

As Nick suggested check the caption, or indeed the name

Const sWSin As String = "Worksheet in " ' English ?

With ActiveWorkbook
b = Left(.Name, Len(sWSin)) = sWSin Or _
Left(.Windows(1).Caption, Len(sWSin)) = sWSin
End With

Probably OK only to check the name.

Regards,
Peter T

"Felix" wrote in message
...
Not confused. That's exactly what I'm trying ;-) , you are right on the

money.
Try this - it will behave the same way as my database scenario.

Open a new Word document then insert an existing Excel file as an Object
(Insert Object .. from file) and select show as icon.

I think the difference between what we are doing is the "show as icon"

part.

Now if you double click on the icon in the Word doc it will open the

Excel
file in the Excel UI. This is how my objects from the database look and

feel.
Now I'm looking for some property or something that will me destinguish

this
object from a never saved file.

Hope I explained this OK.

"Peter T" wrote:

I'm confused, happens often <g

Are you trying to check if a workbook is effectively an inserted

object
in
another app which works in Excel ?

I inserted a workbook in Word, activated it, pressed Alt-F11 and it

opened
Excel's VBE

I selected Worksheet in Document1, then in the immediate window
? thisworkbook.IsInplace
True

Similar if in IE

But I guess I'm not quite following what you are doing.

Regards,
Peter T

"Felix" wrote in message
...
Thanks Peter, Unfortunatelly Lotus Notes (the database the object is
embedded
in) opens the object (file) in Excel and just modifies the Excel

File
Menus
(adds close & return, save copy as and a few other items). Since it

is
(technically) open in Excel the Inplace property is False.
Any other thoughts ?

"Peter T" wrote:

b = wb.IsInplace ' true = embedded

Regards,
Peter T


"Felix" wrote in message
...
I have build an Add-in and capture the Beforesave Event of all

Excel
workbooks my users work with. occasionally my users will open

excel
workbooks
from a database were the files are actually embeded objects. I

have to
treat
these files differently than the files my user manipulates on

the
Hard
drive.
Currently I differentiate them by getting the OpenPath property

from
the
Workbook. If it is an Object OpenPath="" all other files have

OpenPath
=
"<path of some sort" which I then use for further validation.

This
works
great as long as the file I'm working with is not a new workbook

that
has
never been saved, in that instance OpenPath="" which makes my

code
think
it's
opend from the database as an object while it is not.
Anybody can think of an easy way in the beforesave event to
differentiate
the Object from a new workbook ? This is probably realy simple I

can
just
not
think of it right now.