Opening Excel from VBA

Opening Excel from VBA

Anonymous
Not applicable
484 Views
7 Replies
Message 1 of 8

Opening Excel from VBA

Anonymous
Not applicable
I am attempting to open Excel and load a spreadsheet that already exists at a predefined location. I don't want to make Excel visible, however. I just need to open this spreadsheet up and use normal methods for stripping data from the cells.

I know how to get the data from the spreadsheet if Excel is already open at runtime. However, I don't want Excel to be open at runtime. Rather I think I need to ise the "CreateObject" or "GetObject" to open Excel with a spreadsheet already loaded. How is this done?

Thanks for any help...
0 Likes
485 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
dim Excelapp as Excel.application
on error resume next
set Excelapp = GetObject(, "Excel.Application")
if err.number > 0 then
set Excelapp = CreateObject("Excel.Application")
end if

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| AEC Designer / Consultant / Developer
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| "can we make it any easier?!"
0 Likes
Message 3 of 8

Anonymous
Not applicable
Rob, the code you displayed is what i'm using. However, no spreadsheet has been loaded. I need to load a specific spreadsheet into Excel so I can strip data from the cells for use in an AutoLISP program.....
0 Likes
Message 4 of 8

Anonymous
Not applicable
Excelapp.Workbooks.Open "c:\MyFile.xls"

-- Walter -- http://www.ActiveDwg.com



"David_Lister" wrote in message
news:f0aa8d6.1@WebX.maYIadrTaRb...
> Rob, the code you displayed is what i'm using. However, no spreadsheet has
been loaded. I need to load a specific spreadsheet into Excel so I can strip
data from the cells for use in an AutoLISP program.....
>
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
Thanks Rob and Walter. Just curious though... ...I know that the Excel spreadsheet is opened and I have been able to acquire data from it easily, and this is how I want it to function. However, for troubleshooting purposes, is it possible to actually make the Excel Application visible (onscreen) during program execution. I tried using "Excelapp.Visible" (based on the above example) but this apparently gives me a compile error: Invalid use of property. Strange, I have used it before with no problems. Any ideas?
0 Likes
Message 6 of 8

Anonymous
Not applicable
...sorry, let me answer my own question :

Excelapp.Application.Visible = True
0 Likes
Message 7 of 8

Anonymous
Not applicable
Did you try it like this:

Excelapp.Visible = True

-- Walter -- http://www.ActiveDwg.com
0 Likes
Message 8 of 8

Anonymous
Not applicable
Walter Wrote:

>Did you try it like this:
>Excelapp.Visible = True


No, I forgot the "= true" part. This method works as well. Thanks.



[Lisp programmer trying to give VBA a chance 🙂 ]
0 Likes