code to open Excel - worked in Word 2003 does not work in Word 200

R

Russ

I have code that opens a 2003 excel file and extracts data from it into an
array. The code worked fine that last time it was run in Word 2003 but now I
am unable to extract the data in Word 2007. The code later on that used to
extract the data fails in a way that suggests the file is not open.
The following routine opens the Excel file and further routines (not shown)
extract data from a sheet within the file. I added a statement to this
routine to make Excel visible to see if Excel was actually open. The Excel
window opens but the file is not visible. When I close Excel the file in
question appears at the top of the recent list which further indicates that
it was opened. I assume I should see the file in question when this routine
ends. The Excel file has VBA code (had the same code when it opened ok in
Word 2003) in it and I am wondering if I am seeing some sort of security
problem that is causing the problem. What am I missing?
Private Sub open_excel_new_pvcc_data_build_directory()
Dim myname As String
Dim Excelworksheet As Object
myname = "D:\membership robelen\MasterPVCCdata.xls"
Set Excelworksheet = GetObject(myname)
'the next statment was added to see if Excel was really open
Excelworksheet.Application.Visible = True
End Sub
 
R

Russ

It now is working ok after doing nothing. Very strange. Ignore my earlier
email. The file is not visible after the routine but the code that extracts
the data now works fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top