Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Mike Gagnon
  Where is Mike Gagnon?
 Pointe Claire
 Canada
 Mike Gagnon
 To: Khurram Tahir
  Where is Khurram Tahir?
 Karachi
 Pakistan
 Khurram Tahir
 Tags
Subject: RE: GETOBJECT and open Book2 and Book4
Thread ID: 226580 Message ID: 226584 # Views: 24 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Saturday, May 02, 2009 3:39:37 PM         
   


>
Tmpsheet = GETOBJECT('','Excel.Sheet')
> 
> XLApp = Tmpsheet.Application
> 
> XLApp.Visible = .t.
> XLApp.WorkBooks.Add()
> XLSheet = XLApp.ActiveSheet

>
> Q1. Why it is creating 2 Excel files naming Book2 and Book4 how can i avoid 2 Excel files only open and save 1 Excel file from above commands

Tmpsheet = GETOBJECT('','Excel.Sheet')  && This creates an Excel sheet 
XLApp.WorkBooks.Add() && This creates an Excel workbook


So now you have 2 objects created. But this was already explained in another one of your posts. Why not just use

oEx = createobject("Excel.application")
oWB = oEx.WorkBooks.Add()
oEx.Visible = .t.



Mike Gagnon
Refox XI +(English version)



COMPLETE THREAD
GETOBJECT and open Book2 and Book4 Posted by Khurram Tahir @ 5/2/2009 3:24:35 PM
RE: GETOBJECT and open Book2 and Book4 Posted by Mike Gagnon @ 5/2/2009 3:39:37 PM