Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete excel Documents from your project folder

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ndillner343SKL
195 Views, 2 Replies

Delete excel Documents from your project folder

I'm looking to delete an excel document (.xlsx) from my project folder.

 

This is my best attempt,

	'define the file to create/open
	myXLS_File = ThisDoc.Path & "\TempFile.xlsx"
			
'define Excel Application object
	excelApp = CreateObject("Excel.Application")
'set Excel to run visibly, change to false if you want to run it invisibly
	excelApp.Visible = False
'suppress prompts (such as the compatibility checker)
	excelApp.DisplayAlerts = False

	excelWorkbook = excelApp.Workbooks.Delete(myXLS_File) 

 

2 REPLIES 2
Message 2 of 3

if this is iLogic:

 

If System.IO.File.Exists(myXLS_File) Then
    System.IO.File.Delete(MyXLS_File)
End if
Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Reset view Representations | Smart Leader | Copy with Constraints | Part Visibility Utility | Property Editor | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle


Message 3 of 3

In addition on @basautomationservices reply. You can use the function IO.Path.Combine(...) This function will add \ in your path if needed. (I see that you hard coded them in your OP) Because that function will look automatically for you if \ are needed it's less likely for you to get bugs. 

Another thing I like is the FileInfo class. It has all kinds functions that you might need. Your could could look like this.

[iLogic code]

Dim excelFilePath = System.IO.Path.Combine(ThisDoc.Path, "TempFile.xlsx")
Dim excelFileInfo As New System.IO.FileInfo(excelFilePath)
If (excelFileInfo.Exists) Then excelFileInfo.Delete()

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report