'VBA to save progress to master
I am trying to create a workbook of Part numbers that are being reviewed. Once reviewed, there is a macro button that will initialize and date the current workbook and save that over the master. The macro also refreshes the workbook to pull in any new initials and dates before it does the saving to ensure anyone else's progress is kept before overwriting.
The issue is it insists the master is open when I know for a fact it is not. I assume something about the refresh "opens" the file but I do not know of any work-arounds.
Worth noting the error is:
Run-time '1004' Excel Cannot Access
The folder is not restricted and any domain user can access it.
I thought creating a subfile that saves over the master would be the best way to allow multiple people to add their progress throughout the day but perhaps I am wrong.
Below is the code:
Sub Get_Initials()
For Each objConnection In ThisWorkbook.Connections
bBackground = objConnection.OLEDBConnection.BackgroundQuery
objConnection.OLEDBConnection.BackgroundQuery = False
objConnection.Refresh
objConnection.OLEDBConnection.BackgroundQuery = bBackground
Next
Dim strUserName As String
strUserName = Application.UserName
ActiveCell = strUserName
ActiveCell.Offset(ColumnOffset:=1).Activate
ActiveCell = Now()
Application.DisplayAlerts = False
ThisWorkbook.SaveCopyAs Filename:="P:\Master\Part Number List Master.xlsm"
Application.DisplayAlerts = True
End Sub
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
