Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default can we copy the code from the addin to excel workbook

Is there any code thru which we can copy the code from addin to a
excel workbook .. in the addin i have a code written in thisworkbook
and have 1 module ..
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default can we copy the code from the addin to excel workbook


The process requires you to save the macro as a BAS file then read the
BAS file into the 2nd workbook. Chip Pearson has good instructions at
his website

'Programming In The VBA Editor'
(http://www.cpearson.com/excel/vbe.aspx)

Read the two bullets at the top of the webpage carefully especially

•Next, you need to enable programmatic access to the VBA Project. In
Excel 2003 and earlier, go the Tools menu (in Excel, not in the VBA
editor), choose Macros and then the Security item. In that dialog, click
on the Trusted Publishers tab and check the Trust access to the Visual
Basic Project setting.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=175509

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default can we copy the code from the addin to excel workbook

Try something like

Dim TempFile As String
Dim ModuleName As String
Dim FromWB As Workbook
Dim DestWB As Workbook

Set FromWB = Workbooks("YourAddInFile.xla")
Set DestWB = ThisWorkbook
ModuleName = "modConstants"
TempFile = Environ("Temp") & "\" & ModuleName & ".bas"
On Error Resume Next
Kill TempFile
On Error GoTo 0
FromWB.VBProject.VBComponents(ModuleName).Export _
Filename:=TempFile
DestWB.VBProject.VBComponents.Import _
Filename:=TempFile
On Error Resume Next
Kill TempFile
On Error GoTo 0

For modules, use ".bas" as shown in the TempFile = line of code. For
userforms, use ".frm", and for class modules, sheet modules, and
ThisWorkbook, use ".cls". This assumes that the add-in's VBProject is
not locked and that the "Allow Access To The VB Project" is enabled.

See www.cpearson.com/Excel/VBE.aspx for much more detail.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]






On Tue, 2 Feb 2010 02:39:55 -0800 (PST), vicky
wrote:

Is there any code thru which we can copy the code from addin to a
excel workbook .. in the addin i have a code written in thisworkbook
and have 1 module ..

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
how can we embed the code to the excel workbook from addin vicky Excel Programming 5 February 4th 10 09:11 AM
vba addin to copy a workbook [email protected] Excel Programming 0 February 21st 08 02:16 PM
VBA code to copy and paste by values from one Excel workbook to another Nhien Excel Programming 7 August 17th 07 04:06 PM
VB addin excel can't see any workbook [email protected] Excel Programming 0 July 26th 06 03:44 PM
VBA Code to copy a worksheet to another Excel Workbook Hummel Excel Programming 3 November 9th 04 12:54 AM


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