View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
BlairH BlairH is offline
external usenet poster
 
Posts: 10
Default Open a file and execute code

For a bit of background info, I want to create a template file that users
will fill out as a form. This will then execute code to copy the info to a
separate log file stored on a network server. I want to have the code in the
log file as opposed to the template file so that it can be more readily
updated. For various reasons I am unable to do this in MSAccess, which would
be orders of magnitude easier.

Thanks!

"BlairH" wrote:

I'm trying to open a file and execute code in that file. Here's what I've got:

Private Sub Workbook_Open()

WName = ActiveWorkbook.Name
LogFileName = "C:\NCR_db.xls" ' Set the name and location of the
log file
Workbooks.Open Filename:=LogFileName ' open the log file
LFName = ActiveWorkbook.Name ' return the name of the workbook
Workbooks(WName).Activate

Call Test_code_exec ' pass control to
the main code

End Sub

I keep getting an undefined Sub or Function error. The file doesn't open so
it look slike the error occurs before the code exexcutes - VB is trying to
identify all of its calls before execution, and since this is in a different
file it doesn't recognize it.

The Declare statement allows you to identify external subroutines in DLLs,
but can you specify that the code is external in another VB Project / Excel
file?

This is in XL2003.

Thanks,

Blair