HELP: opening/closing Excel remotely!!!!

J

jille

Hi,

I have a complex Word macro that creates an Excel file from a template for
use within the macro. During a session the user may need to create multiple
Excel files.

I'm using the following code to open Excel and create the new file, by
declaring and then creating the procedure that follows:

Public xlbookbulk As Object

then, as a separate procedure:

With Excel.Application
Workbooks.Open vPath & "\EnBulk Information.xlt"
..Application.Visible = True
Set xlbookbulk = .ActiveWorkbook
vBulkFileName = .ActiveWorkbook.Name
End With

Everything works wonderfully until the user closes the current/first Excel
file and attempts to construct a new one. The file is constructed but it
doesn't view...you can see the Excel toolbars and the formula and status bars
but the area in the centre (where the cells would normally appear) is void,
ie the screen behind is showing through. Strangely enough, the file is
actually there because you can cursor around and the Name box changes cells.

Now if you don't close the Excel file, you can create a new one
successfully. I'm wondering if the problem might have something to do with
Excel's status in Word...it thinks it's still open but it's not?????????

Any ideas? Is there a way to clear the contents of 'xlbokbulk' before
creating the new file?

Thanks,
Jille
 
N

NickHK

You need to be more clear in your coding. Assuming you are using late
binding:

Dim XLApp as object
dim WB as object

set xlapp=creatobject("Excel.Application")
xlapp.visble=true
set wb=xlapp.workbooks.open(vPath & "\EnBulk Information.xlt")
vBulkFileName=wb.name
'....
wb.close, true
set wb=nothing
xlapp.quit
set xlapp=nothing

NickHK
 

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