Message 1 of 11
close workbook after "edit via spreadsheet"

Not applicable
04-27-2009
11:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a macro that will send a command to inventor to edit the iTable 'via spreadsheet'. Similarly as if you right clicked on the iTable and chose "edit via spreadsheet" from the menu. Here's the code
Sub Edit_Via_Spreadsheet()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oDocName As String
oDocName = oDoc.DisplayName
'Opens table via spreadsheet:
' Get the CommandManager object.
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager
' Get control definition for the line command.
Dim oControlDef As ControlDefinition
'open iTable spreadsheet in MSExcel:
Set oControlDef = oCommandMgr.ControlDefinitions.Item( _
"Applaunchviaspreadsheetcmd")
Call oControlDef.Execute
DoEvents
Dim oExlDoc As Workbook
Set oExlDoc = Excel.Workbooks("Worksheet in " & oDocName & ".xls")
oExlDoc.Close savechanges:=False
End Sub
I want to be able to automatically close the workbook that opens. I get the whole way down to setting 'oExlDoc as the workbook and get a "subscript out of range" error. Anyone see what i'm doing wrong here?
thanks
Sub Edit_Via_Spreadsheet()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oDocName As String
oDocName = oDoc.DisplayName
'Opens table via spreadsheet:
' Get the CommandManager object.
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager
' Get control definition for the line command.
Dim oControlDef As ControlDefinition
'open iTable spreadsheet in MSExcel:
Set oControlDef = oCommandMgr.ControlDefinitions.Item( _
"Applaunchviaspreadsheetcmd")
Call oControlDef.Execute
DoEvents
Dim oExlDoc As Workbook
Set oExlDoc = Excel.Workbooks("Worksheet in " & oDocName & ".xls")
oExlDoc.Close savechanges:=False
End Sub
I want to be able to automatically close the workbook that opens. I get the whole way down to setting 'oExlDoc as the workbook and get a "subscript out of range" error. Anyone see what i'm doing wrong here?
thanks