Open a file with VBA Inventor

Open a file with VBA Inventor

Anonymous
Not applicable
14,177 Views
14 Replies
Message 1 of 15

Open a file with VBA Inventor

Anonymous
Not applicable

Hello Cany you tell me how can i open a file with VBA from Invenotr Thanks

Accepted solutions (1)
14,178 Views
14 Replies
Replies (14)
Message 2 of 15

MechMachineMan
Advisor
Advisor
I'm sure google could accomplish the task of answering this exact question.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 15

Anonymous
Not applicable

I found this but id doesent work, can you help me?

 

Sub OpenDoc()

Dim oDoc As Document

oDoc = _InvApplication.Documents.Open _

("C: Temp\Part1.ipt")

End Sub

Message 4 of 15

MechMachineMan
Advisor
Advisor
If you are using VBA rather than vb.net you will need to use Call And Set.

ie; Sub OpenDoc() Dim oDoc As Document Set oDoc = _InvApplication.Documents.Open("C: Temp\Part1.ipt") End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 15

Anonymous
Not applicable

Untitled.png

0 Likes
Message 6 of 15

MechMachineMan
Advisor
Advisor
Try putting it on separate lines.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 7 of 15

Anonymous
Not applicable

Hello when i try to start my project in VB i bekommen this message:

 

1.PNG

0 Likes
Message 8 of 15

rossano_praderi
Collaborator
Collaborator
Accepted solution
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("c:\test.xls")

objExcel.Application.Visible = True

objExcel.ActiveWorkbook.Close
objExcel.Application.Quit

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 9 of 15

Anonymous
Not applicable

Sorry for tagging onto an old thread, but how could I do this to open a .txt file?

0 Likes
Message 10 of 15

frederic.vandenplas
Collaborator
Collaborator
Process.Start("c:\example.txt")
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 11 of 15

Anonymous
Not applicable

It comes up with object required?

0 Likes
Message 12 of 15

frederic.vandenplas
Collaborator
Collaborator

This should work

 

Sub OpenTextFile()

Dim oTextFile As Variant
oTextFile = Shell("notepad.exe ""C:\test.txt""", vbNormalFocus)

End Sub

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 13 of 15

Anonymous
Not applicable

Thank you! This is perfect 🙂

Message 14 of 15

Anonymous
Not applicable

This works for me but only as Read-Only, any insights on how to fix this?

0 Likes
Message 15 of 15

rossano_praderi
Collaborator
Collaborator

Hi,

when we use the Excel application object you should use the help of that application as reference.

 

The follow option to control read/write mode for the "Open" method.

 

Set objWorkbook = objExcel.Workbooks.Open("c:\test.xls",, False)

 

 For reference see...

https://msdn.microsoft.com/en-us/VBA/Excel-VBA/articles/workbooks-open-method-excel

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------