Shared workbook

Gilang

New Member
Joined
Feb 21, 2021
Messages
48
Office Version
  1. 2007
Platform
  1. Windows
I have a workbook that is turned into a data center, while the data processing excel file resides on a different computer. After each data is processed, all results are copied to the central workbook.
Can I find out that a datacenter workbook is still open on another computer with a macro message?
if possible can anyone help me with the syntax?
 
There is indeed a writing syntax like this:

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub TutMelody()
On Error Resume Next
Application.ScreenUpdating = False
Dim sWAVFile As String
sWAVFile = "C:\Windows\Media\Quirky\Windows Navigation Start.wav"
On Error Resume Next
PlaySound sWAVFile, 0
If ERR.Number Then ERR.Clear
Application.ScreenUpdating = True
On Error GoTo 0
End Sub


Does that affect your syntax?
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I just checked and the errNum = Err should work and not go to uppercase
I don't think I can solve this.

The only thing you can try for the catastrophic error you had and the Err changing to ERR is check if your VBA settings Tools > Reference are the same as mine below. (This is purely on the basis that I am not getting either of those issues.

In your code you have Hosting and that is not a file path and definitely won't work.
I am also not sure what would work on a OneDrive file.

1615104370887.png
 
Upvote 0
The macro needs the full path and file name of the file you are trying to check.
Unless you have defined what Hosting means (eg Hosting = "FilePath\Filename"), the macro has no idea what this is.

Based on the screen shot "File Location", I think you are going to find checking the file is not going to be a simple matter.
You indicated you wanted to check a file at the data center, however the File Location given is a OneDrive file and the address is the file on someone's C drive.
This is a copy of the server file on an individual's computer. I don't think you will be able to access that nor will it tell you if the server copy is open.

If you can get the full server FilePath & FIleName you could try that but accessing OneDrive & Sharepoint files is particularly challenging.
If its a standard Network stored file then the function should work as long as you have to full name.
I use the function to define Hosting so that as shown in the message box like the image, later I will connect it with my OneDrive
 

Attachments

  • hosting.jpg
    hosting.jpg
    13.8 KB · Views: 2
Upvote 0
I just checked and the errNum = Err should work and not go to uppercase
I don't think I can solve this.

The only thing you can try for the catastrophic error you had and the Err changing to ERR is check if your VBA settings Tools > Reference are the same as mine below. (This is purely on the basis that I am not getting either of those issues.

In your code you have Hosting and that is not a file path and definitely won't work.
I am also not sure what would work on a OneDrive file.

View attachment 33703
I set up a tool like this
 

Attachments

  • References VBA.jpg
    References VBA.jpg
    63.1 KB · Views: 1
Upvote 0
Have you run it with the file Data.xlsx open ?
ie open the file in Excel then run the macro.
 
Upvote 0
I have opened it, and run the macro, but the value is still 0, I don't know what happened to my project, but I have done it in another way
I hope it is corrected for the better
VBA Code:
Public Sub createPJ()
Dim hst As String
hst = Userform1.LHost.caption
With Application
.ScreenUpdating = False
.DisplayAlerts = False
Dim NewBook As Workbook
    Set NewBook = Workbooks.Add
    With NewBook
        .SaveAs Filename:=Host & "\PJ.text"
        .Close
    End With
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub

'CEK FILE------------------------------------------------------------
Sub ChkData()
Dim FlName As String

FlName = Host & "\PJ.text"

Ulangi:
If Dir(FlName) <> "" Then
    Psn = MsgBox("Busy...," & vbNewLine & vbNewLine & _
            "try again...?", vbInformation + vbYesNo, "BUSY")
            If Psn = vbYes Then
                GoTo Ulangi
            Else
                GoTo Lanjut
            End If
Lanjut:
    Exit Sub
Else
    createPJ
              msgbox "Your data can be copied to the destination data",,"WBK FREE"
    hapusPJ
End If
end sub


Sub HapusPJ()
Dim hst As String
hst = Userform1.LHost.caption
On Error GoTo MsgErr
Dim wbName As String
    wbName = Host & "\PJ.text"
    Kill wbName
Exit Sub
MsgErr:
MsgBox wbName & " tidak ada", , ""
End Sub
 
Last edited by a moderator:
Upvote 0
I have a problem changing the Err syntax but it immediately changes to ERR, please give me a solution
All that means is that you have, or had, something called ERR in your code - a routine, a variable, a module etc.
 
Upvote 0

Forum statistics

Threads
1,215,401
Messages
6,124,705
Members
449,182
Latest member
mrlanc20

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top