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: 

Automating Pack and Go from Excel using VBA

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
1387 Views, 4 Replies

Automating Pack and Go from Excel using VBA

Hi all,

 

I'm working on a project where Vault has not been adopted. For the drawings, the control measure we have adopted is to pack and go each drawing as we send it off for checking; if it comes back OK, we issue that drg, and the pack and go data is kept on file as a snapshot of the 3d info associated with the drawing. 

 

I would like to automate this from Excel using VBA, with a view to being able to run multiple pack and go exports in a batch.

Reasons for using this approach are are: 1 - I'm pretty confident with VBA; 2 - the drawing register is in Excel, and there is useful info in there about that governs where the drawing and associated 3d snapshots should be saved.

 

Unfortunately I've fallen at the first hurdle. This is my code so far:

Option Explicit
Option Base 1


Public Sub PublishMinorRev()
    Dim oPnGComp As New PackAndGoLib.PackAndGoComponent
    Dim oPnG As PackAndGoLib.PackAndGo
    oPnG = oPnGComp.CreatePackAndGo(ThisWorkbook.Path & "\Block.dwg")
End Sub

 When run from Excel it fails with the error: "Run time Error '429': ActiveX component can't create object". I can use similar code to create a pack and go object from within the Inventor VBA IDE just fine.

 

I have enabled the "PackAndGoLib" and "Autodesk Inventor Object Library" in Excel, as they are in Inventor. One thing I have noticed is that the location of the DLL files for the Autodesk Inventor Object Library differs between Excle and Inventor; Excel seems to be using the 32-bit version (in C:\Program Files\Autodesk\Inventor 2015\Bin\Bin32), where as Inventor references C:\Program Files\Autodesk\Inventor 2015\Bin\.

 

I've googled around the error message, and there are loads of forum posts about AutoCAD and its change over from 32 to 64 bit, and the various problems that caused some people. My Excel VBA version is 7.1, which I understand to be 64 bit.

 

Can anyone help me either:

  • Get around the error
  • Find another way of achieving what I want to do

Thanks in advance

Tags (3)
4 REPLIES 4
Message 2 of 5
YuhanZhang
in reply to: Anonymous

Can you try VB.net to see if the problem solves? We have a VB.net sample in API help:

 

Public Sub PackAndGoSample()
    Dim oPacknGoComp As New PackAndGoLib.PackAndGoComponent

    Dim oPacknGo As PackAndGoLib.PackAndGo
    oPacknGo = oPacknGoComp.CreatePackAndGo("C:\Temp\Source\Assembly1.iam", "C:\Temp\Destination")

    ' Set the design project. This defaults to the current active project.
    oPacknGo.ProjectFile = "C:\Temp\Source\Test.ipj"

    Dim sRefFiles = New String() {}
    Dim sMissFiles = New Object

    ' Set the options
    oPacknGo.IsSkippingLibraries = True
    oPacknGo.IsSkippingStyles = True
    oPacknGo.IsSkippingTemplates = True
    oPacknGo.IsCollectingWorkgroups = False
    oPacknGo.IsKeepingFolderHierarchy = True
    oPacknGo.IncludeLinkedFiles = True

    ' Get the referenced files
    oPacknGo.SearchForReferencedFiles(sRefFiles, sMissFiles)

    ' Add the referenced files for package
    oPacknGo.AddFilesToPackage (sRefFiles)

    ' Start the pack and go to create the package
    oPacknGo.CreatePackage()
End Sub

 

 

 

 

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 5
Anonymous
in reply to: YuhanZhang

Thanks for the code sample Rocky. Unfortunately, I don't think I have access to VB.NET. It requires Visual Studio (I think), which I don't have.

Message 4 of 5
ekinsb
in reply to: Anonymous

I suspect the problem is a 32 vs. 64 bit issue.  I'm guessing that you're running 32-bit Excel which also means you have 32-bit VBA.  VBA 7.1 does support 64-bit but there is also a 32-bit version.  The easiest way I've found it to run the application and look in task manager.  If the name has "*32" after it then it's running as a 32-bit application, like my Excel is as shown below.  There is a 64-bit version of office and the Pack and Go component should work in it.

 

32BitExcel.png


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 5
Anonymous
in reply to: ekinsb

Thanks Brian. It looks like I am indeed running 32 bit Excel. I'll have to get on to our IT people to see if they can get me onto 64bit...

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

Post to forums  

Autodesk Design & Make Report