I would like to have my Word XP macro grab a value from the registry in order to determine if a certain network printer here at work is installed on their machine. Does reading registry values in VBA cause any sort of corruption? I had previously written a macro for use here at work that wrote a value to the registry and after people used it, some of the users reported errors when trying to use certain unrrelated documents "the document could not be registered" microsoft says that this error occurs when the registry has been corrupted. I just wanted to make sure my code did not corrupt the registry. here was the code i used:
Dim MySettings As Variant
MySettings = GetSetting(appname:="Printer", Section:="Docketing", Key:="Exists")
DPFPrinter = "DPFprint"
CurrentPrinter = Application.ActivePrinter
If MySettings = 1 Then
Documents.Add Template:=NormalTemplate.FullName
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
frmMain.Show
Else:
On Error Resume Next
Application.ActivePrinter = DPFPrinter
myPrinter = Left(Application.ActivePrinter, 8)
'Check to see if the docketing printer is installed
If myPrinter <> DPFPrinter Then
MsgBox "You do not have the docketing printer installed. Please contact the Help Desk."
Exit Sub
End If
Application.ActivePrinter = CurrentPrinter
SaveSetting appname:="Printer", Section:="Docketing", Key:="Exists", setting:=1
Documents.Add Template:=NormalTemplate.FullName
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
frmMain.Show
End If
Dim MySettings As Variant
MySettings = GetSetting(appname:="Printer", Section:="Docketing", Key:="Exists")
DPFPrinter = "DPFprint"
CurrentPrinter = Application.ActivePrinter
If MySettings = 1 Then
Documents.Add Template:=NormalTemplate.FullName
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
frmMain.Show
Else:
On Error Resume Next
Application.ActivePrinter = DPFPrinter
myPrinter = Left(Application.ActivePrinter, 8)
'Check to see if the docketing printer is installed
If myPrinter <> DPFPrinter Then
MsgBox "You do not have the docketing printer installed. Please contact the Help Desk."
Exit Sub
End If
Application.ActivePrinter = CurrentPrinter
SaveSetting appname:="Printer", Section:="Docketing", Key:="Exists", setting:=1
Documents.Add Template:=NormalTemplate.FullName
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
frmMain.Show
End If