Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Making Default Code Apply to Preexisting Workbooks

I have been trying to slug out the solution to this for a couple of days now;
I know just enough to look up solutions in the VBA help and try and figure it
out from there.

Anyway, what I'm trying to do for my office is automate some document
controls that we now require in the form of custom headers and footers; some
of the data is created/stored in custom document properties and other data
are custom formulae--I have no problem with this. The first time I click
save or print when the document is open, I want it to validate the custom
document properties and/or give me a chance to change them ... and then
update the headers & footers for each worksheet in the workbook.

I have setup a new default Book.xls & Sheet.xls for every new document I
create. So, in new workbooks, everything I want to happen works superbly;
it's the old workbooks that I can't figure out.

Ideally, when I open an old workbook, I'd like to have a button on a custom
toolbar that would run the code from my default Book.xls on the old document,
storing my desired custom headers & footers. I'd also like to add the
functionality of the BeforeSave & BeforePrint from that works so brilliantly
in the default Book.xls. I'm thinking the only way to do this is to copy the
code verbatim from the default Book.xls into my old document with this
button? This could potentially present a problem when I have to distribute
it to the 30 or so people on my team across the country if there is any hard
file paths involved. Any ideas? Remember, I know just enough to be
dangerous.

Thanks, in advance, for your help.--JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Making Default Code Apply to Preexisting Workbooks

Use envirnoment parameters to get the users My document directory

UserName = environ("UserName") or replace user name with any of the
environmental parameters found below.


to get a list of all the environmental parameter on your PC you need to open
a Dos window

From XP
1) Start - Run
2) type in run box CMD.EXE
3) A dos window wil open. On the command line type
SET then return

From vista
1) Start - Find
2) In the find box type CMD.Exe
3) A dos window wil open. On the command line type
SET then return


"JT Klipfer" wrote:

I have been trying to slug out the solution to this for a couple of days now;
I know just enough to look up solutions in the VBA help and try and figure it
out from there.

Anyway, what I'm trying to do for my office is automate some document
controls that we now require in the form of custom headers and footers; some
of the data is created/stored in custom document properties and other data
are custom formulae--I have no problem with this. The first time I click
save or print when the document is open, I want it to validate the custom
document properties and/or give me a chance to change them ... and then
update the headers & footers for each worksheet in the workbook.

I have setup a new default Book.xls & Sheet.xls for every new document I
create. So, in new workbooks, everything I want to happen works superbly;
it's the old workbooks that I can't figure out.

Ideally, when I open an old workbook, I'd like to have a button on a custom
toolbar that would run the code from my default Book.xls on the old document,
storing my desired custom headers & footers. I'd also like to add the
functionality of the BeforeSave & BeforePrint from that works so brilliantly
in the default Book.xls. I'm thinking the only way to do this is to copy the
code verbatim from the default Book.xls into my old document with this
button? This could potentially present a problem when I have to distribute
it to the 30 or so people on my team across the country if there is any hard
file paths involved. Any ideas? Remember, I know just enough to be
dangerous.

Thanks, in advance, for your help.--JT

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
Apply footer code to all new workbooks Billy Rogers[_2_] Excel Programming 1 November 14th 07 09:01 PM
Exporting and Importing Data into a preexisting Workbook rtheissen Excel Programming 2 July 10th 06 09:36 PM
How do I apply a default size to all comments in Excel worksheet? Alt0471 Excel Discussion (Misc queries) 1 May 25th 05 08:57 PM
Making comments apply to more than one cell Evelyn Excel Discussion (Misc queries) 2 February 9th 05 12:08 AM


All times are GMT +1. The time now is 04:22 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"