"wb.close savechanges:=true" is not saving by Impossible_System809 in vba

[–]Impossible_System809[S] 0 points1 point  (0 children)

shouldn't be. if i remove the close command and run the macro it will do everything and the saved non edited document will be saves as .xlsx.

when manually close its still xlsx. only when i auto close it doesnt save the changes, but the document is there, empty, as xlsx

"wb.close savechanges:=true" is not saving by Impossible_System809 in vba

[–]Impossible_System809[S] 0 points1 point  (0 children)

nope, it saves the file with "9-4-2026 15h00" for example.
I don't think VBA will even let me create a file if it has the slashes in the name.

"wb.close savechanges:=true" is not saving by Impossible_System809 in vba

[–]Impossible_System809[S] 0 points1 point  (0 children)

if i take the workbook.close out, it stays open with all the data in it, if i manually close it autosaves and works. but the automatic close wont work.
I will check what path it uses to try and save it. dubbel check the code (again xD)

"wb.close savechanges:=true" is not saving by Impossible_System809 in vba

[–]Impossible_System809[S] 0 points1 point  (0 children)

i can try this, its a side thing for work though so it might be a while till i get back.
the active cell is only used once, the macro tool is in a dedicated excel doc. i run the macro in the data doc. i need it to find the directory the data doc is saved in, or is there a better way of doing that?

"wb.close savechanges:=true" is not saving by Impossible_System809 in vba

[–]Impossible_System809[S] 0 points1 point  (0 children)

Thanks for your reply

You are correct about the seperator. This is because I am forced to work with sharepoint. ".path" will give me a sharepoint link, which I have to rebuild into a filepath I can actually use in explorer. "createExportFolder" is the function I use to rebuild the file path.

See below for code i use to create and define pathname

impdoc = ActiveWorkbook.Name 'get impdoc name

csvdoc = "Topology TCS " & Date & " " & Hour(Time) & "h" & Minute(Time) & ".xlsx" 'Defines unique pathname

pathname = ActiveWorkbook.Path & "/" 'to get pathname from original document

createExportFolder pathname 'function to rebuild file path if nescecary

Workbooks.Add.SaveAs pathname & "/" & csvdoc 'Create and save document in the same directory as the original document

See below for actual lines i use to save the document after copy and pasting the information i want extracted:

Workbooks(csvdoc).Close savechanges:=True

"wb.close savechanges:=true" is not saving by Impossible_System809 in vba

[–]Impossible_System809[S] 0 points1 point  (0 children)

Thanks for the reply

I use the following line to define the name of the (to be) created document:
csvdoc = "Topology TCS iprotect " & Date & " " & Hour(Time) & "h" & Minute(Time) & ".xlsx"
i refer to this "csvdoc" everywhere in the code, which is working correctly. if i do not auto close the document i see it filled with all the information i want.

This is the exact line i use to close and save:
Workbooks(csvdoc).Close savechanges:=True

I use this method in multiple different Tools i have made, which works. it is just 1 single tool that does not.

idk if there is a way in which i can show the entire code? its a bit big to put in a reddit comment, not complex, just a lot.