Fehler mit ActiveDocument.Path

Ötzi

Mitglied
Hallo,

Ich habe eine Excel Datei aus welcher ich mittels VBA Dateien auslese und in eine Datei speichern möchte.

Klappt soweit auch wunderbar, nur leider liefert mir die Zeile "ActiveDocument.Path" den Fehler "Object Required" - woran könnte das liegen?

Hier mein Code:
Code:
Private Sub Schaltfläche1_BeiKlick()
myPath = ActiveDocument.Path
Open myPath & "\config.xml" For Output As #1
Print #1, "<?xml version=""1.0"" encoding=""ISO-8859-1"" ?>"
Print #1, "<config>"
Print #1, "  <soldtoparty>"
Print #1, "    <company>" & ThisWorkbook.Worksheets("Tabelle1").Cells(4, 2).Value & "</company>"
Print #1, "    <department>" & ThisWorkbook.Worksheets("Tabelle1").Cells(5, 2).Value & "</department>"
Print #1, "    <street>" & ThisWorkbook.Worksheets("Tabelle1").Cells(6, 2).Value & "</street>"
Print #1, "    <city>" & ThisWorkbook.Worksheets("Tabelle1").Cells(7, 2).Value & "</city>"
Print #1, "    <postcode>" & ThisWorkbook.Worksheets("Tabelle1").Cells(8, 2).Value & "</postcode>"
Print #1, "  </soldtoparty>"
Print #1, "  <material>"
Print #1, "    <code>" & ThisWorkbook.Worksheets("Tabelle1").Cells(11, 2).Value & "</code>"
Print #1, "    <description>" & ThisWorkbook.Worksheets("Tabelle1").Cells(12, 2).Value & "</description>"
Print #1, "    <price>" & Replace(ThisWorkbook.Worksheets("Tabelle1").Cells(13, 2).Value, ",", ".") & "</price>"
Print #1, "  </material>"
Print #1, "</config>"
Close #1

MsgBox "The config file has successfully been created"
End Sub
Danke im Vorraus,
mfg
 
führt App.Path anstatt ActiveDocument.Path zum gewünschten ergebnis ?

das schreibt dann dahin wo die vb datein liegen
 
App.Path hat leider den gleichen Fehler verursacht.

Aber ich hab mir jetzt einen Workaround gebaut. In Excel erzeuge ich einfach mit mittels
Code:
=LINKS(ZELLE("Dateiname";A4);FINDEN("[";ZELLE("Dateiname";A4))-1)
den Pfad zu meinem Worksheet und lese dann in VBA dieses Feld ein - klappt soweit super!
 
Zurück