All Questions
319 questions
0
votes
1
answer
78
views
Infinite loop while closing another workbook
I'm working on an Excel project where I use VBA and two workbooks :
One to update some tables (analysis requests updated with a macro while opening) and another one where I copy part of those tables ...
1
vote
1
answer
53
views
Save picture from excel to a file
I have an excel where I import some pictures (from a onedrive file, they are uploaded as part of a query). These pictures are part of an auto-response PDF I will generate from my excel file, that ...
0
votes
0
answers
66
views
VBA Excel thisworkbook.saved changes inexplicably
My goal is to close a file without being prompted to save after changing a shape, specifically the size of a button; to this end, after changing the button, I set Thisworkbook.saved to True but if I ...
0
votes
1
answer
96
views
Messagebox for overwriting files does not pop up
I have written the following VBA code to save my Solidworks files. It also checks if files already exists in the folder and if so - asks through a messagebox if these files need to be overwritten.
...
1
vote
1
answer
86
views
Temporarily replace values in string
I have a very simple question for you, but I cannot find it on the internet.
I have a list called ArrayList(i) of which I want to replace some strings for only one line. After that line, it should be ...
0
votes
1
answer
79
views
Overwrite files msgbox within a loop using Solidworks vba
I have a script that saves x amount parts of a SW assembly into step/xt, based on the input of a userform.
This works really well. However, I want to add a messagebox that asks "Do you want to ...
0
votes
0
answers
50
views
Open part that contains a certain value in Solidworks using vba
I wrote a script that automatically saves multiple parts within a Solidworks assembly using a Userform and VBA.
In my userform, I have multiple checkboxes that the user can click that will be saved. ...
0
votes
2
answers
73
views
Creating separate folders to save attachments
I am trying to look through old emails to scan them to save the attachment and the email while creating separate folders for said attachment.
Sub SaveAttachmentsToDynamicFolders()
Dim olApp As ...
1
vote
1
answer
150
views
Microsoft Excel VBA Save As CSV Subroutine - File Cannot Be Accessed Error
For an end user on my team the following subroutine fails to save a CSV file with an error message that states "'OUTLOOK MERGE DATA.CSV' cannot be accessed. The file may be corrupted, located on ...
0
votes
1
answer
59
views
Pressing CTRL+S will execute a macro on a sheet
I just want a simple conditional code where if a user press the shortcut Ctrl+S this will execute
Cells.EntireColumn.AutoFit
Thank you
I only know this code but i dont know what else to use to ...
1
vote
2
answers
443
views
How do I save each worksheet in a workbook as a separate file?
This code works great except that is saves every worksheet in the workbook. I need it to save each worksheet in the workbook as a separate file. I need it to save each tab separately giving the new ...
0
votes
1
answer
46
views
Save a macro enabled workbook based on 3 cell values
I am trying to add a code to save a workbook based on 3 cell values. A little background, we have a planner at work that we need to make daily backup, or copies as needed without altering the original ...
0
votes
2
answers
44
views
Saving Bound tables manually (VBA)
I have a form bound to a table, but when I save, for which I have a button, I need to do some manual flag setting. The saving works, but I noticed that because it's bound, it saves anyway. How can I ...
0
votes
1
answer
80
views
Excel VBA macro works flawlessly on my computer, but has different errors on different machines?
I'm working on a project which works without macros so far. When implementing macros, my machine executes them without errors, but when testing it on other machines for other users, they have issues ...
1
vote
1
answer
61
views
VBA Word changing command button properties prevents closing without save prompt
I want to be able to close my MS Word 2021 document without being prompted to save it, and I have added the following code:
Sub Document_Close()
ActiveDocument.Saved = True
End Sub
This works as ...
0
votes
0
answers
39
views
Excel VBA unable to save file on a network drive
I am trying to save a copy of my file using vba on a network drive. The code was working fine earlier however it has stopped working and gives Subscript our of range error.
As per the debug, code ...
0
votes
0
answers
29
views
Copy multiple worksheets from workbook and create a new workbook and save this file to new destination with name change and break links
I am trying to take multiple worksheets from workbook and save them to a new workbook with a new name and destination. when I have (122, 222) to save multiple worksheets its doesn't let me run it only ...
1
vote
1
answer
51
views
Copy worksheet from workbook and create a new workbook and save this file to new destination with name change
I am trying to take one worksheet from a workbook, create a new workbook, and then save it to a new folder and name it December. This code runs through, but it opens a new workbook and doesn't save it ...
0
votes
0
answers
33
views
Fill a blank cell with a color before save, but clear it when data is entered in VBA
I have code that prevents a user from saving a file if certain cells are empty. The code fills the necessary cells with a jarring red color that forces the user to enter data before attempting to save ...
0
votes
1
answer
30
views
Save in exisiting folder
I want this code to always save the pdf in the same location as the file.
If I do not manual resave this file before running the code, the pdf ends up in a different location.
Sub ...
0
votes
1
answer
670
views
Outlook Macro To Replace Com Addin
I'm currently looking at options to replace a Com addin I had programmed to store sent and recieved emails. As MicroSoft has decided Com Add ins will no longer be supported with the new version of ...
0
votes
1
answer
100
views
VBA - Can't save workbook due to a naming error. (Error 1004) Not sure how to fix the program
Function export_to_csv(ws As Worksheet, filename As String, filepath As String, fileRange As String)
Dim LastRow As Long
Application.ScreenUpdating = False
If ws.AutoFilterMode Then Cells.AutoFilter
...
2
votes
0
answers
157
views
Save instance of a class module in VBA/Excel
I have a project for my Excel file, it's something like a project with branch on git.
I have a main object :
Private member1 as String
Private member2 as String
Private list as Collection
Public Sub ...
0
votes
0
answers
47
views
VBA: How read a .txt-File and put a string into label
I'am new at VBA (no Excel). My problem is...
I want to read a .txt-File from a path named "C:\Users\Marc\Desktop\Unterlagen\Datei.txt" and put the data from a line into a label. This for ...
0
votes
2
answers
214
views
If cells in range not in date format dd-mm-yy then prohibit saving the file
I have an Excel worksheet where users paste their data.
To save (save, save as or crtl+s) the data has to conform to conditions.
If the non-empty cells in the first column do not have the date format ...
0
votes
1
answer
154
views
run macro on Save of Another Workbook from XLSM file
Hi Guys i have a small issue that I need help with.
I got a xlsm file named "vba.xlsm" that I have set in a directory to be automatically open when any excel file is open. This using open At ...
0
votes
0
answers
146
views
Function Save in excel vba is acting as SaveAs
I have a macro, and I am struggeling with saving. The macro:
opens second workbook from SharePoint
unprotects it
unprotects a sheet in the original workbook
copies line(s)
pastes those line(s) in the ...
2
votes
0
answers
155
views
How to save Dictionary object to bin file in VBA?
This is VBA case. I want to save Dictionary object to bin file and put it again back to Dictionary later. This object should be the only content of bin file. In general I am stuck on:
Compile error: ...
4
votes
1
answer
65
views
Save Worksheet to PDF and Create a Directory When Needed, for both Windows and MacOS
I'm in a bit of fix here as this code works perfectly for windows [my own OS].
The aim of the code is to save a particular worksheet in a filename each time. If the directory doesn't exist, it will ...
0
votes
0
answers
63
views
Why does with ActiveWorkbook.Sheets(1) work with a .saveas in the statement?
To preface, I am fairly intermediate with VBA. I'm curious as to why the following code works.
Dim report_wb as Workbook, _
str_savepath, str_reportname as String
Set report_wb = ...
0
votes
1
answer
36
views
Excel VBA code breaks after saving document. (ActiveCell.Address & ActiveCell.Name)
I have the following script to copy range of the active cell to clipboard and it works fine untill I save the document (without closing it) after which it breaks:
Sub getCellSheetAndAddress()
Dim ...
1
vote
0
answers
54
views
Workbook contain macro save as new workbook
I have workbook contain macro. The report name is ppAug22.xlsm. Every month I will save new workbook - ppSep22.xlsm containing macro inside the new workbook. I put all the file path and new file name ...
0
votes
0
answers
64
views
Suppress an Excel Error message caused by save button before going into `Workbook_BeforeSave` event
While manually saving an Excel Addin file as xla I'm unable to suppress an Excel eror message.
The error measage occurs before the Workbook_BeforeSave event is triggered.
In Workbook_BeforeSave event ...
0
votes
1
answer
268
views
Specifying file name when saving using VBA in excel returning a blank
I am trying to get this code to work but when the save dialogue opens the suggested file name is blank. I traced the variable "saveFile" in the locals window and it's false instead of the ...
0
votes
2
answers
88
views
Function that will check if there is already a folder by that name
I'm trying to create a save function that will check if there is already a folder by the name specified in Range G3 and if there is, it will just save the file. If there isn't it will create a new ...
0
votes
1
answer
1k
views
How to prevent saving when cells are blank but to allow me to save the blank template
I have a template that I need to send to various people in my company to use. Normally, half of them leave specific information I need blank when they return the form (despite multiple warnings from ...
1
vote
0
answers
504
views
How can I save an Excel sheet as a PDF to two different locations at once?
I am trying to get this VBA macro to save the selection from an Excel sheet as a PDF but in two different locations. The reason is part of the company seems to use OneDrive as their default directory ...
0
votes
2
answers
36
views
errorhandeling does not work on SaveAs if file already open
I have a small code that needs to run when closing the excel file.
the file needs to make a copy that is read only so that the original can be amended at the same time.
this part works if the readonly ...
2
votes
1
answer
486
views
Save model from drawing
I have VBA code to issue drawings. It allows properties of the model to be changed, issue, date of issue etc.
The idea is to open the drawing, update issue, date, etc. (save as pdf and dwg). It works, ...
0
votes
0
answers
23
views
Save Workbook as .xlsm [duplicate]
I am trying to save my workbook via Macro.
Unfortunately with the following code it will be saved as a .txt file.
I also tried using FIlterIndex = 2 but it didn't work at all.
Does anyone have the ...
1
vote
1
answer
1k
views
Using the Current Month in a Folder Path in VBA Code
When I run this code I get an error message
"compile error: named argument not found".
Sub SavetoCurrentMonth()
Application.DisplayAlerts = False
' Check for month ...
0
votes
0
answers
2k
views
Excel VBA cannot complete an export in xlsx from SAP
I'm an absolute beginner in Sap script and just a beginner in Excel Vba (my scarse knowledge comes mostly from your kind community), so be patient.
I'm trying to launch from Excel Vba a data ...
0
votes
1
answer
5k
views
EXCEL ExportAsFixedFormat to save some sheets
Good morning,
Sub pdfs()
Application.ScreenUpdating = False
Dim i As Integer
Dim nome_arquivo As String
For i = 5 To Sheets.Count
nome_arquivo = Sheets(i).Name
With Sheets(i)
.ExportAsFixedFormat ...
-2
votes
1
answer
187
views
Save SPREADSHEETS in multiple excel files with the name of the main file
I have an Excel file with 4 auxaliary sheets + 7 sheets with tables.
I would like to copy and separate each sheet (of the 7 sheets) into multiple excel's, so that each excel file has only 1 table. ...
0
votes
1
answer
3k
views
Save file in newly created folder: Runtime error method save of object _workbook failed
I am trying to:
Check a specified folder to make sure a folder with the name current year exists. If not, create it.
Copy everything from Sheet1 of the already open workbook to a newly added workbook.
...
0
votes
1
answer
2k
views
Writing and Saving to a PDF with VBA
I have been able to successfully write to a pdf, but now I am trying to save it. I know I need to use a pddoc in order to save, but I can't set it to match the avdoc that I use to write to the pdf. ...
0
votes
1
answer
129
views
Open File Password Prompt While Closing
I have two separated workbooks with macroces: Book1 with Macro1 and Book2 with Macro2.
Macro1 is simple code to:
hidely open Book2 (has an open password: 1111);
write "test" in A1 Active ...
0
votes
0
answers
153
views
VBA Save a Workbook
There is my code where I try to Save a Workbook in a specific place:
Private Sub zouzou()
Nom = Cherche("Z:\3_BASE\WORK\BD\01 - PRODUCTION\" & SE & "\" & Batch &...
0
votes
0
answers
116
views
How to save workbook opened as read-only
I have trouble saving WB that is opened as a read-only (from SharePoint server). Tried to add ReadOnly:=False to line that opens up the workbook, but vba still stopps and points to line wb_gr.Save.
Is ...
0
votes
1
answer
4k
views
How to save copy of Excel workbook?
I've been trying to make a macro that automatically saves a backup copy of my Excel workbook before I edit any of its data.
Every time I call it, even though it successfully saves a new copy, when it ...