Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep Focus on excel file 1

Status
Not open for further replies.

math20

MIS
Jul 7, 2005
71
CA
Hi,

I am working with access database, one of the process is to import an excel file, before I import I need to delete the blnak cells and other data that I do not need. I am using this code:
Dim RetVal
Dim strSettledFile As String
RetVal = Shell("C:\Program Files\microsoft office 2003 pro\OFFICE11\excel.exe", 3)
to open an excel application,but right after it opens the excel application the program executes other codes without giving the me/user the option to open any excel file.
I would like the code to give focus to this excel application where I can open any excel file then execute some codes that deletes some cells and then give me an option to save this excel file, like save as option.

Is it possible?
 
Have a look at OLE Automation.
A starting point:
Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.Workbooks.Open("\path\to\file.xls")
Set objXL.Visible = True
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Could you please explain this part of the code:
Set objWB = objXL.Workbooks.Open("\path\to\file.xls")

Path=?
to=?
file=?

Because when it runs the createObject it creates the excel but how do I find out where it is and what it is called like book1 or book2?
 
OK, seems you don't have too much knowledge about the Excel object model.
A different way:
CreateObject("WScript.Shell").Run "Excel", 3, True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top