ExcelVBA Connect to CATIA Excel two way
ฝัง
- เผยแพร่เมื่อ 23 พ.ย. 2024
- 🚴🏽Excel VBA connect CATIA and excel
Sub CATMain()
Dim Excel As Object
On Error Resume Next
Set Excel = GetObject(, "Excel.Application")
'set the workbook as the active document
Set WBK = Excel.ActiveWorkbook.Sheets(1)
Debug.Print WBK.Name
Debug.Print CATIA.ActiveDocument.Name
Debug.Print CATIA.ActiveDocument.Sheets.ActiveSheet.Name
'Send to Excel information from CATIA
WBK.Range("B1").Value = CATIA.ActiveDocument.Name
WBK.Range("B2").Value = CATIA.ActiveDocument.Sheets.ActiveSheet.Name
End Sub
👩💻Programming CATIA macros with Visual Basic for Applications
👩💻Programming CATIA macros with Visual C#
CATScript
CATVBS
CATVBA
Microsoft VBScript
Microsoft Visual Studio
ASP.Net C#
**Thank you very much**
Can you make a version checker for catia pls? I tried myself but I failed at reading version. If you open lower version it will be warn you.
Let use below to check it, sir.
Dim version as string
version = CATIA.SystemConfiguration.Version 'is 5 if using V5
Dim release as string
release = CATIA.SystemConfiguration.Release 'is 20 if using R20
@@thingsredraw How about part and products last versions? Starting catia you enter your part or product and app says last saved version of part or product file. And your current catia too. For example your part is made in r19 and you opened in r22 this app will warn you your current catia
@@ChillingGamerr Let ref below for your needing.
Sub catmain()
Dim strFilePath As String
strFilePath = "C:\Users\Desktop\SWITCH_RH_M_OFO.CATPart"
Dim FSO As Object, buf As String
Set FSO = CreateObject("Scripting.FileSystemObject")
With FSO.GetFile(strFilePath).OpenAsTextStream
buf = .readall
.Close
End With
Set FSO = Nothing
Dim pos As Long
pos = InStr(1, buf, "", vbBinaryCompare)
Debug.Print "Version " & Mid(buf, pos + 9, 1)
pos = InStr(1, buf, "", vbBinaryCompare)
Debug.Print "Release " & Mid(buf, pos + 9, 2)
pos = InStr(1, buf, "", vbBinaryCompare)
Debug.Print "ServicePack " & Mid(buf, pos + 13, 1)
End Sub