Guten Morgen zusammen,
ich habe folgendes Problemchen, ich habe eine VBA Routine mit der ich immer dateien in eine Stepdatei exportiere. Nun kommt es vor das wir in der "Bezeichung1" in den Iprops die für die Dateinamensgebung abgefragt wird ein Sonderzeichen wie z.B. ein / vorhanden ist. Dies führt dazu das diese Routine die Datei aus irgendwelchen Gründen nicht mehr ablegen kann ? Folgend die Routine - ich hoffe jemand hat eine Idee - Für alle hilfe ein dank schon mal!
Sub Export_Step()
'Reference zum Aktiven Dokument erstellen
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument
Dim bErr As Boolean
Dim fso As Object
Set fso = CreateObject("Scripting.FilesystemObject")
Dim ret As Variant
Set dDoc = ThisApplication.ActiveDocument
'Nachricht fall Dokument noch nicht gespeichert ist
If dDoc.FullFileName = "" Then
MsgBox "Bitte zuerst die Datei speichern... "
Exit Sub
End If
'PDF translator Add-In ansprechen
Dim oSTEPTranslator As TranslatorAddIn
Set oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
'NameValueMap object erstellen
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'DataMedium object erstellen
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
Dim oZeichNr As Inventor.Property
On Error GoTo ErrorHandler
Set oZeichNr = dDoc.PropertySets(4).Item("Zeichnungsnummer")
Dim oRevNr As Inventor.Property
On Error GoTo ErrorHandler
Set oRevNr = dDoc.PropertySets(4).Item("Index")
Dim oName As Inventor.Property
On Error GoTo ErrorHandler
Set oName = dDoc.PropertySets(4).Item("Bezeichnung1")
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
' Set application protocol.
' 2 = AP 203 - Configuration Controlled Design
' 3 = AP 214 - Automotive Design
oOptions.Value("ApplicationProtocolType") = 3
' Other options...
'oOptions.Value("Author") = ""
'oOptions.Value("Authorization") = ""
'oOptions.Value("Description") = ""
'oOptions.Value("Organization") = ""
oContext.Type = kFileBrowseIOMechanism
'Dateinamen mit Pfad erstellen
If bErr = False Then
oDataMedium.fileName = "C:\GAIN\Exchange\" & "\" & oZeichNr.Value & "_" & oRevNr.Value & "-" & oName.Value & ".stp"
Else
oDataMedium.fileName = "C:\GAIN\Exchange\" & NameSplit(oDocument.FullFileName) & ".stp"
End If
'Dokument puplizieren
End If
Call oSTEPTranslator.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
MsgBox "STEP wurde unter -- C:\GAIN\Exchange -- gespeichert!!"
Exit Sub
ErrorHandler:
bErr = True
Resume Next
End Sub
MFG
------------------
MFG
BlueJay
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP