PC Review


Reply
Thread Tools Rate Thread

Activate a template file

 
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      23rd Oct 2007
Using Office 2003 and Windows XP;

Is there any way to activate a template file after it has already been
opened (but not yet saved)?

I tried recording the file name and writing it into a hidden sheet, then use
that to activate the file, but it doesn't work, I guess because it is not yet
saved, but it seems there must be a way to activate it.

I also tried setting an object reference to the file on open, but this loses
the object reference for some reason, I think because the file being opened
is an Oracle ADI template file and certain codes run in the background to
connect to Oracle and the object reference is severed in the process.

Can I use a window name perhaps?

Your example code would be most appreciated. Thanks much in advance.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      23rd Oct 2007
Do the open with a set statement. After a workbook open the opened workbook
is the active workbook. Set a variable to the active workbook. Later use
the variable to activate the book again

workbooks.open filename:=MyName.xlt
set templ = activeworkbook

'later in the code
templ.activate

"XP" wrote:

> Using Office 2003 and Windows XP;
>
> Is there any way to activate a template file after it has already been
> opened (but not yet saved)?
>
> I tried recording the file name and writing it into a hidden sheet, then use
> that to activate the file, but it doesn't work, I guess because it is not yet
> saved, but it seems there must be a way to activate it.
>
> I also tried setting an object reference to the file on open, but this loses
> the object reference for some reason, I think because the file being opened
> is an Oracle ADI template file and certain codes run in the background to
> connect to Oracle and the object reference is severed in the process.
>
> Can I use a window name perhaps?
>
> Your example code would be most appreciated. Thanks much in advance.

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      23rd Oct 2007
> workbooks.open filename:=MyName.xlt
> set templ = activeworkbook


Or, simpler,

Set WB = Workbooks.Open(Filename:="YourTemplate.xlt")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Joel" <(E-Mail Removed)> wrote in message
news:2240B288-99D1-4188-B40B-(E-Mail Removed)...
> Do the open with a set statement. After a workbook open the opened
> workbook
> is the active workbook. Set a variable to the active workbook. Later use
> the variable to activate the book again
>
> workbooks.open filename:=MyName.xlt
> set templ = activeworkbook
>
> 'later in the code
> templ.activate
>
> "XP" wrote:
>
>> Using Office 2003 and Windows XP;
>>
>> Is there any way to activate a template file after it has already been
>> opened (but not yet saved)?
>>
>> I tried recording the file name and writing it into a hidden sheet, then
>> use
>> that to activate the file, but it doesn't work, I guess because it is not
>> yet
>> saved, but it seems there must be a way to activate it.
>>
>> I also tried setting an object reference to the file on open, but this
>> loses
>> the object reference for some reason, I think because the file being
>> opened
>> is an Oracle ADI template file and certain codes run in the background to
>> connect to Oracle and the object reference is severed in the process.
>>
>> Can I use a window name perhaps?
>>
>> Your example code would be most appreciated. Thanks much in advance.


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      24th Oct 2007
One more:

Dim Wkbk as workbook
set wkbk = workbooks.add(template:="C:\yourtemplate.xlt")
'then work with the wkbk variable.
Wkbk.worksheets(1).range("a1").value = "hi there"

(I've never worked with the Oracle stuff, though. Not sure how it would affect
you.)

XP wrote:
>
> Using Office 2003 and Windows XP;
>
> Is there any way to activate a template file after it has already been
> opened (but not yet saved)?
>
> I tried recording the file name and writing it into a hidden sheet, then use
> that to activate the file, but it doesn't work, I guess because it is not yet
> saved, but it seems there must be a way to activate it.
>
> I also tried setting an object reference to the file on open, but this loses
> the object reference for some reason, I think because the file being opened
> is an Oracle ADI template file and certain codes run in the background to
> connect to Oracle and the object reference is severed in the process.
>
> Can I use a window name perhaps?
>
> Your example code would be most appreciated. Thanks much in advance.


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      30th Oct 2007
Thanks everyone for your posts; actually the Oracle ADI somehow causes
automation to lose/drop the reference to the template file. So using "Set
wrkBook =" did not function in any method tried.

However, I did find that I could "manually" get a reference to the template;
when the template is opened, the program writes the file name into a hidden
sheet, then the following function can re-activate the unsaved template file:

Public Function FileTemplateActivate(argFileName As String)
'FUNCTION DETERMINES IF FILE IS CURRENTLY OPEN;
Dim wrkBooks As Workbooks
Dim wrkBook As Workbook
Set wrkBooks = Application.Workbooks
For Each wrkBook In wrkBooks
If UCase(wrkBook.Name) = UCase(argFileName) Then
Workbooks(wrkBook.Name).Activate: Exit Function
Next wrkBook
End Function

Thanks to everyone for trying to help. Maybe this post will help someone else?


"Dave Peterson" wrote:

> One more:
>
> Dim Wkbk as workbook
> set wkbk = workbooks.add(template:="C:\yourtemplate.xlt")
> 'then work with the wkbk variable.
> Wkbk.worksheets(1).range("a1").value = "hi there"
>
> (I've never worked with the Oracle stuff, though. Not sure how it would affect
> you.)
>
> XP wrote:
> >
> > Using Office 2003 and Windows XP;
> >
> > Is there any way to activate a template file after it has already been
> > opened (but not yet saved)?
> >
> > I tried recording the file name and writing it into a hidden sheet, then use
> > that to activate the file, but it doesn't work, I guess because it is not yet
> > saved, but it seems there must be a way to activate it.
> >
> > I also tried setting an object reference to the file on open, but this loses
> > the object reference for some reason, I think because the file being opened
> > is an Oracle ADI template file and certain codes run in the background to
> > connect to Oracle and the object reference is severed in the process.
> >
> > Can I use a window name perhaps?
> >
> > Your example code would be most appreciated. Thanks much in advance.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP! Activate a .msg file R Ritt Microsoft Outlook Discussion 3 26th Jan 2009 05:02 PM
Activate Embedded Email Template Jinx Microsoft Powerpoint 1 5th Feb 2008 03:23 PM
Activate File Properties Dialog upon Opening File Andy Microsoft Powerpoint 6 30th Aug 2004 08:12 PM
Re: Activate File Properties Dialog upon Opening File Andrew Kneeland Microsoft Powerpoint 0 30th Aug 2004 07:17 PM
Re: Activate File Properties Dialog upon Opening File Andrew Kneeland Microsoft Powerpoint 0 30th Aug 2004 04:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:39 PM.