LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default excel to autocad routine opens a new instance of excel that has no worksheet.

Mary,
Looks like GetObject is failing because there is no instance of Excel
running, so you are creating a new empty instance, even though that code is
commented out in your sample.
Also, whilst not the cause your problem, it would be better to use something
like "XLApp" instead of "excel" for the variable name.

Assuming ACAD VBA behaves the same as in Office, this line really means
nothing:
If Err<0 Then
because you have no "On Error Resume Next" before GetObject. So if there is
an error, it will not be handled.

So basically your is code is working (after you add "On Error Resume Next").
But because you need to work with the current XL file, you should exit your
code if GetObject fails, because you have nothing to work with.
Also, you do know that if you have more than 1 instance of Excel running,
GetObject will give access to 1 instance essentially at random. So you may
not get the reference to workbook you desire.

NickHK

wrote in message
oups.com...
Here is the code
Mary
----------
Dim rng As Range


Dim excel As Object
Dim acad As Object

-------- Excess code cut -------------
Private Sub CommandButton1_Click()

EXAMPLE_GETVARIABLE

Set excel = GetObject(, "Excel.Application")
If Err < 0 Then
Err.Clear
'Set excel = CreateObject("Excel.Application")
'If Err < 0 Then
'MsgBox "Could not load Excel.", vbExclamation
'End
'End If
End If
On Error GoTo 0

excel.Visible = True
mysheet = excel.ActiveWorkbook.ActiveSheet.Name
Set excelsheet = excel.ActiveWorkbook.Sheets(mysheet)
Set rng = excel.Application.InputBox(Prompt:="Select range", Type:=8)
begrow = rng(1).Row

--------------- Excess code cut -----------


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Opens but no worksheet Margy Excel Discussion (Misc queries) 3 February 1st 09 02:30 PM
Inserting .dwg file in excel opens the drawing in autocad... Mohan Excel Worksheet Functions 0 July 18th 07 08:36 AM
How do I copy an entire worksheet to another instance of excel? Alan Excel Programming 7 June 30th 05 06:06 AM
Excel opens without a visible worksheet Raul Excel Programming 0 November 1st 04 03:32 PM
Excel ADO connection opens read-only instance of opened Excel Serge L Excel Programming 6 September 23rd 03 07:39 PM


All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"