Macro for opening Excel spreadsheet on specific sheet

This widget could not be displayed.

Macro for opening Excel spreadsheet on specific sheet

Anonymous
Not applicable

Hello,

I have a macro in my AutoCAD to open an excel spreadsheet and it works just fine. But I'd like it to open that spreadsheet on a specific sheet, not the first one of the workbook.

Here is what I have:

^C^C(startapp "C:/Program Files (x86)/Microsoft Office/Office15/excel.exe" "S:/CADStockbill.xlsx #ACAD_collection")

 Name of the sheet is ACAD_collection. But it opens the excel file on the first sheet of the worksbook. Is there a way to make it work?

 

I'm running AutoCAD 2016 x64 on Windows 10 Pro.Using Excel 2013.

Thank you.

0 Likes
Reply
1,443 Views
2 Replies
Replies (2)

leeminardi
Mentor
Mentor

The worksheet that is active when Excel is opened is the worksheet that was active when the file was last saved.  The simple answer to your question is to select the worksheet ACAD_Collection before saving the Excel file.  

 

You could also add a VBA macro to your Excel file to control what appears when the file is opened.   For example,  create the following in the ThisWorkbook VBAProject object:

 

Sub Workbook_Open()

Sheets("ACAD_Collection").Select

End Sub

 

 

~Lee

lee.minardi

Anonymous
Not applicable

Hi, thanks, that's what I've done, I dealt with it inside the excel by using VBA code. I just thought there was a way to enter it directly into a macro in Autocad. But this works just as good. I haven't tried saving in the worksheet last opened, but I guess that would work too.

Thanks for your time.

0 Likes