Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Importing Code into 'ThisWorkbook'

I am using Excel 97.

I have a chunk of code which I need to import into
the 'ThisWorkbook' module of a workbook. It cannot be in
an 'addin' as the workbook is sent out on email and this
would mean sending the xla file with the workbook, this
would cause a lot of confusion to recipients who are
unfamiliar with EXCEL.

When I try to import it, it places it in a 'Class module'
and not the 'ThisWorkbook' part.

Can anyone assist, please?

Thanks


Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Importing Code into 'ThisWorkbook'

It imports it into a class module because ThisWorkbook is a class module,
and when you export it, it is exported to a .cls file. It has then lost any
reference to the specific class, and treats it as any other.

You could try AddFromFile. Save the code in a text file and use this code

ActiveWorkbook.VBProject.VBComponents("ThisWorkboo k") _
.CodeModule.AddFromFile "C:\myTest\Text1.txt"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
I am using Excel 97.

I have a chunk of code which I need to import into
the 'ThisWorkbook' module of a workbook. It cannot be in
an 'addin' as the workbook is sent out on email and this
would mean sending the xla file with the workbook, this
would cause a lot of confusion to recipients who are
unfamiliar with EXCEL.

When I try to import it, it places it in a 'Class module'
and not the 'ThisWorkbook' part.

Can anyone assist, please?

Thanks


Mark



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Importing Code into 'ThisWorkbook'

Bob,

Many thanks - it works :-)

Mark

-----Original Message-----
It imports it into a class module because ThisWorkbook

is a class module,
and when you export it, it is exported to a .cls file.

It has then lost any
reference to the specific class, and treats it as any

other.

You could try AddFromFile. Save the code in a text file

and use this code

ActiveWorkbook.VBProject.VBComponents("ThisWorkbo ok") _
.CodeModule.AddFromFile "C:\myTest\Text1.txt"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in

message
...
I am using Excel 97.

I have a chunk of code which I need to import into
the 'ThisWorkbook' module of a workbook. It cannot be

in
an 'addin' as the workbook is sent out on email and

this
would mean sending the xla file with the workbook, this
would cause a lot of confusion to recipients who are
unfamiliar with EXCEL.

When I try to import it, it places it in a 'Class

module'
and not the 'ThisWorkbook' part.

Can anyone assist, please?

Thanks


Mark



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Importing Code into 'ThisWorkbook'

Mark,

That's good. An added benefit is that it adds, whereas import (if it worked)
is the whole thing. The problem is that you could add an event that is
already present.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
Bob,

Many thanks - it works :-)

Mark

-----Original Message-----
It imports it into a class module because ThisWorkbook

is a class module,
and when you export it, it is exported to a .cls file.

It has then lost any
reference to the specific class, and treats it as any

other.

You could try AddFromFile. Save the code in a text file

and use this code

ActiveWorkbook.VBProject.VBComponents("ThisWorkbo ok") _
.CodeModule.AddFromFile "C:\myTest\Text1.txt"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in

message
...
I am using Excel 97.

I have a chunk of code which I need to import into
the 'ThisWorkbook' module of a workbook. It cannot be

in
an 'addin' as the workbook is sent out on email and

this
would mean sending the xla file with the workbook, this
would cause a lot of confusion to recipients who are
unfamiliar with EXCEL.

When I try to import it, it places it in a 'Class

module'
and not the 'ThisWorkbook' part.

Can anyone assist, please?

Thanks


Mark



.



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
2007 View Code ThisWorkbook KC hotmail com> Excel Discussion (Misc queries) 2 February 24th 10 09:07 PM
Importing Alan Beban's code on Arrays; Importing a module or a project Steve G Excel Worksheet Functions 4 August 27th 07 04:18 PM
Importing Uni Code (Big-Endian) Text data Qazi Imran Excel Discussion (Misc queries) 0 December 26th 06 09:14 AM
Delete the code in ThisWorkbook Darrin Henry Excel Programming 1 October 1st 03 11:10 PM
Code in ThisWorkbook crashes Excel Pat Beck Excel Programming 6 August 25th 03 09:07 AM


All times are GMT +1. The time now is 09:42 AM.

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

About Us

"It's about Microsoft Excel"