View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
g-boy g-boy is offline
external usenet poster
 
Posts: 5
Default Opening a Workbook in the Background

"George Nicholson" wrote:
Dim acts much like Private. If you want the variable to be recognized by
another module, use Public:
Public objApp As Excel.Application


Thank you... I didn't know that. I figured "dim" was generic, with "Public"
and "Private" as special cases.

However, unfortunately *just* changing the declaration line to

Public objApp As Excel.Application

in the ThisWorkbook declaration didn't fix the problem... I still get an
"Object Required" error on the line:

Set DataSheet = objApp.Workbooks("Data.xls").Sheets(1)

in the code for the worksheet.

Could this be because one is declarated in the code for the workbook, but
the subroutine that uses the variable is in the code for the worksheet? Do I
need to do something to explicitly declare the thing as "global" or something?