Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Object vs. New File in beforeSave event

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Object vs. New File in beforeSave event

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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Object vs. New File in beforeSave event

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.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Object vs. New File in beforeSave event

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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Object vs. New File in beforeSave event

Felix,
Can you check the .Caption ?
For a new book, I get "Book 15"

But for an embedded object I get something like 'Worksheet in Document 1"

NickHK

"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.










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Object vs. New File in beforeSave event

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.








  #7   Report Post  
Posted to microsoft.public.excel.programming
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.










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
BeforeSave Event Question Andibevan[_4_] Excel Programming 0 August 11th 05 11:35 AM
BeforeSave event Carl Bowman Excel Discussion (Misc queries) 4 February 6th 05 12:28 PM
Make "BeforeSave" event supply a default path and file name? quartz Excel Programming 1 April 22nd 04 08:08 PM
BeforeSave event j23 Excel Programming 0 April 6th 04 11:15 AM
BeforeSave workbook event Cindy Excel Programming 15 February 10th 04 04:28 PM


All times are GMT +1. The time now is 05:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"