![]() |
|
#1
|
|||
|
|||
![]()
I found this code:
Code:
Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") arrRegPaths = Array( _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset1\", _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset2\", _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset3\", _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset4\" _ ) Const intForReading = 1 Const intUnicode = -1 strFileName = objShell.ExpandEnvironmentStrings("%UserProfile%") & "\Desktop\RegKeys.reg" For Each strRegPath In arrRegPaths strCommand = "cmd /c REG EXPORT " & strRegPath & " " & Replace(strRegPath, "\", "_") & ".reg" objShell.Run strCommand, 0, True Set objRegFile = objFSO.CreateTextFile(strFileName, True, True) objRegFile.WriteLine "Windows Registry Editor Version 5.00" If objFSO.FileExists(Replace(strRegPath, "\", "_") & ".reg") = True Then 'WScript.Sleep 1000 ' Wait one second to give the file time to close Set objInputFile = objFSO.OpenTextFile(Replace(strRegPath, "\", "_") & ".reg", intForReading, False, intUnicode) If Not objInputFile.AtEndOfStream Then objInputFile.SkipLine objRegFile.Write objInputFile.ReadAll End If objInputFile.Close Set objInputFile = Nothing objFSO.DeleteFile Replace(strRegPath, "\", "_") & ".reg", True End If objRegFile.Close Set objRegFile = Nothing Next MsgBox "Finished." |
#2
|
|||
|
|||
![]()
*UPDATE:
running this will give the error/stop Runtime Error 91, Object Variable or With block Variable not set. Code:
Private Sub CommandButton1_Click() Dim objShell As Object Dim objFSO As Object Dim arrRegPaths As Object Dim strFileName As Object Dim objRegFile As Object Dim strRegPath As Object Dim strCommand As Object Dim objInputFile As Object 'Dim objShell As Object Dim objInputFire As Object Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") arrRegPaths = Array( _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset1", _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset2", _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset3", _ "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\PNPreset4" _ ) Const intForReading = 1 Const intUnicode = -1 strFileName = objShell.ExpandEnvironmentStrings("%UserProfile%") & "\Desktop\PageNumberer_settings.reg" Set objRegFile = objFSO.CreateTextFile(strFileName, True, True) objRegFile.WriteLine "Windows Registry Editor Version 5.00" For Each strRegPath In arrRegPaths strCommand = "cmd /c REG EXPORT " & strRegPath & " " & Replace(strRegPath, "\", "_") & ".reg" objShell.Run strCommand, 0, True If objFSO.FileExists(Replace(strRegPath, "\", "_") & ".reg") = True Then 'WScript.Sleep 1000 ' Wait one second to give the file time to close Set objInputFile = objFSO.OpenTextFile(Replace(strRegPath, "\", "_") & ".reg", intForReading, False, intUnicode) If Not objInputFile.AtEndOfStream Then objInputFile.SkipLine objRegFile.Write objInputFile.ReadAll End If objInputFile.Close Set objInputFile = Nothing objFSO.DeleteFile Replace(strRegPath, "\", "_") & ".reg", True End If Next objRegFile.Close Set objRegFile = Nothing MsgBox "Finished." End Sub |
#3
|
||||
|
||||
![]()
REM all the following lines:
Code:
'Dim arrRegPaths As Object 'Dim strFileName As Object 'Dim objRegFile As Object 'Dim strRegPath As Object 'Dim strCommand As Object 'Dim objInputFile As Object 'Dim objShell As Object 'Dim objInputFire As Object -Shelby |
#4
|
|||
|
|||
![]() Quote:
|
#5
|
|||
|
|||
![]()
ah ha! got it to work now with alternate changes. verifying.
|
#6
|
|||
|
|||
![]()
new problem. I got this far, now the *.reg file is empty (other than "Windows Registry Editor Version 5.00
"). What to do to tell this code to properly input the registry values as noted in the lines starting with HKEY_CURRENT_USER. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to find and remove duplicate entries in Listboxes? | olympiatr | CorelDRAW/Corel DESIGNER VBA | 6 | 26-07-2010 20:29 |
Exporting | Iluvtheravens | General | 1 | 14-03-2007 15:32 |
exporting to PSD | zoom | General | 2 | 14-11-2006 12:23 |
Sorting entries in the object manager | dan | CorelDRAW/Corel DESIGNER VBA | 1 | 18-08-2004 23:16 |
exporting to jpg | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 7 | 26-01-2004 12:53 |