Save an excel spreadsheet from the Inventor VBA

Save an excel spreadsheet from the Inventor VBA

shastu
Advisor Advisor
1,777 Views
2 Replies
Message 1 of 3

Save an excel spreadsheet from the Inventor VBA

shastu
Advisor
Advisor

I am trying to save an excel spreadsheet from the Inventor VBA.  What do I have to do to get it to work.  It works from an excel VBA but not when I paste it into my Inventor VBA.  This is my code where sProp is a variable.

 

ActiveWorkbook.Saveas FileName:="C:\Users\ShaStu\Documents\" & sProp & ".xlsx", _
        FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

0 Likes
Accepted solutions (1)
1,778 Views
2 Replies
Replies (2)
Message 2 of 3

sajith_subramanian
Autodesk Support
Autodesk Support

Hi shastu,

 

Below is a piece of code from another discussion that does something similar.

 

 

Sub CreateExcelDoc()
    
    Dim AppXls As Excel.Application
    Dim wb As Excel.Workbook
    Dim ws As Excel.WorkSheet
    
    Set AppXls = CreateObject("Excel.Application")
    Set wb = AppXls.Workbooks.Add
    
    Set ws = wb.Worksheets.Item(1)
    
    'Putting dummy values
    ws.Range("A1").Value = "Cell A1"
    ws.Range("A2").Value = "Cell A2"
    ws.Range("A3").Value = "Cell A3"
    
    wb.SaveAs ("C:\TEMP\TestCreate.xls")
    Call wb.Close

End Sub

 

Let me know if it helps.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
Message 3 of 3

shastu
Advisor
Advisor
Accepted solution

This worked:

 

excel_app.ActiveWorkbook.Saveas FileName:="C:\Users\ShaStu\Documents\" & sProp & ".xlsx"