• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

workbook opslaan naar andere bestanden

Status
Niet open voor verdere reacties.

promoboy

Gebruiker
Lid geworden
5 feb 2012
Berichten
14
Ik wil van een workbook 7 bestanden willen maken om later samen te voegen en te vergelijken.

Ik zou ook maar eenmalig willen kiezen in welk path ik het wil opslagen

Ik heb volgende code gemaakt maar het werkt niet:

Code:
Sub BestandenMaken()
Dim FileFormatValue As Long
Dim Tornooi As String, MasterFile As String, Poule1File As String, Poule2File As String, Poule3File As String, Poule4File As String, Poule5File As String, Poule6File As String

Tornooi = Sheets("START").Range("D3").Value

MasterFile = "C:\Documents and Settings\My Documents\VAS\Master"" " & Tornooi & ".xlsm"
Poule1File = "C:\Documents and Settings\My Documents\VAS\Poule1"" " & Tornooi & ".xlsm"
Poule2File = "C:\Documents and Settings\My Documents\VAS\Poule2"" " & Tornooi & ".xlsm"
Poule3File = "C:\Documents and Settings\My Documents\VAS\Poule3"" " & Tornooi & ".xlsm"
Poule4File = "C:\Documents and Settings\My Documents\VAS\Poule4"" " & Tornooi & ".xlsm"
Poule5File = "C:\Documents and Settings\My Documents\VAS\Poule5"" " & Tornooi & ".xlsm"
Poule6File = "C:\Documents and Settings\My Documents\VAS\Poule6"" " & Tornooi & ".xlsm"

ActiveWorkbook.SaveAs Filename:=MasterFile, FileFormat:=FileFormatValue = 52, CreateBackup:=False

If ActiveSheet.Range("C10").Value = "" Then GoTo poule2:
ActiveWorkbook.SaveAs Filename:=Poule1File, FileFormat:=FileFormatValue = 52, CreateBackup:=False
poule2:
If ActiveSheet.Range("D10").Value = "" Then GoTo poule3:
ActiveWorkbook.SaveAs Filename:=Poule2File, FileFormat:=FileFormatValue = 52, CreateBackup:=False
poule3:
If ActiveSheet.Range("E10").Value = "" Then GoTo poule4:
ActiveWorkbook.SaveAs Filename:=Poule3File, FileFormat:=FileFormatValue = 52, CreateBackup:=False
poule4:
If ActiveSheet.Range("F10").Value = "" Then GoTo poule5:
ActiveWorkbook.SaveAs Filename:=Poule4File, FileFormat:=FileFormatValue = 52, CreateBackup:=False
poule5:
If ActiveSheet.Range("G10").Value = "" Then GoTo poule6:
ActiveWorkbook.SaveAs Filename:=Poule5File, FileFormat:=FileFormatValue = 52, CreateBackup:=False
poule6:
If ActiveSheet.Range("H10").Value = "" Then Exit Sub
ActiveWorkbook.SaveAs Filename:=Poule6File, FileFormat:=FileFormatValue = 52, CreateBackup:=False
End Sub
 
Laatst bewerkt:
"het werkt niet" is wat kort door de bocht.
Wat werkt er niet? Krijg je een foutmelding?
Zoja, wat zegt deze dan?
Of werkt het anders dan je zou willen?
 
Ik krijg een foutmelding

Fout 1004 tijdens uitvoering
Methode SaveAs van Object_workbook is mislukt
 
Dat betekend dus dat 1 van de opdrachten ActiveWorkbook.SaveAs fout gaat.
 
Ik heb de fout gevonden:

het moet zijn:
Code:
wbBook.SaveAs MasterFile, FileFormat:=52, CreateBackup:=False

in plaats van
HTML:
wbBook.SaveAs Filename:=MasterFile, FileFormat:=FileFormatValue = 52, CreateBackup:=False
 
Goed gedaan :thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan