I am using PIPUTVAL to allow operators to input sample data into the database. Everything works exactly like I would like it to on my computer. However, when I moved the Excel Workbook to the network, it stopped working. I traced the problem to their connection to the database on their computer. For some reason, their machine will not automatically connect to the default server. When I open the workbook and force a connection then run my code, it works. I don't want to get called at 4am just because they don't make the connection first. So my question is, do you have a piece of VBA code that will auto-connect to the default server?
Hi Rodney:
To connect to the default server this little code snippet should get you started:
'# DECLARE YOUR VARIABLES:
Dim myPIServer As Server
'# CONNECT TO YOUR PI SERVER:
Set myPIServer = Servers.DefaultServer '~ Optional: Servers("YourPIServerNameHere")
If myPIServer.Connected = False Then
myPIServer.Open
End If
Source: VBA Code to Connect To Your PI Server and Output the Name
NOTE: You will first need to add the following "references" in your VBA Code. This is done by simply navigating to [Tools]=>[References]. This launches the "References - VBA Project" dialog box. Here you scroll and then check "PISDK 1.3 Type Library" and "PISDKCommon 1.0 Type Library".