View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default File Path Issue in Excel 2016 for Mac

GS wrote:

GS wrote:

GS wrote:

Sub whereAmI()
Cells(1, 1).Value = ActiveWorkbook.Path
End Sub

Just a minor point, but depending on context it's a very important
point!

VBA 'best practice' suggests:

- use ActiveWorkbook only when the code is acting on or
referencing a
workbook other than itself;

- use ThisWorkbook when code refs the workbook running the code.

Good point.

I figured since you program in other languages that you'd pick up on
the 'This' part of an object ref-ing itself!


I just put down the first thing that came to mind, and didn't really
put any thought into it. Since it's meant to be a one-time-only sorta
thing, I'm not terribly worried about it. (Also, I'm much more used to
Activewhatever, because my code is often run from the personal macro
workbook rather than the workbook being affected.)


Yeah, nothing 'wrong' with that; -my stuff in PERSONAL.xls is configured
that way too! Given the scenario it's perfectly acceptable. Different
story, though, if the workbook was saved hidden, or was an addin, or
Excel had one of its common burps during the load process.

Are you aware that if the file gets corrupted the Workbook_Open event
may not even fire? I stopped using it many ions ago and replaced the
open/beforeclose events with the autorun macros Auto_Open and Auto_Close
and redirect from there.


New one on me. I don't have much that happens in _Open, just something that
finds which columns hold which data and sets some globals -- but believe me,
I'd notice PDQ if that macro didn't fire.

FWIW
I've just got into the habit of following best practice rules in a more
strict way than most VBAers, more so now due to the strictness in
programming in C# more recently, but mostly because I'm also a long-time
dedicated follower of the "Professional Excel Development" principles
which also strongly advocate following best practice rules.


On the one hand, I try to do "best practices" when and where feasible (if I
am aware of said best practices), but on the other hand, I'm not a
"professional". Shrug.

Your helpful contributions here are appreciated; -I hope you keep
following thess Excel NG


I've been posting here since 2003; the odds of me leaving are pretty slim.

--
the perfect mix of cute and psycho