G
Guest
HELP! I'm stalling out. I created this last year for use in a Word document.
Is that why it's not working in Excel? It bombs on the "SerialNumber =
System.PrivateProfileString("C:\Setting.txt", "MacroSettings",
"SerialNumber")" line. It doesn't go any further than that, so I don't know
if it will work past that, either. If there's anything here that you think
wouldn't work in Excel or any tips on how to troubleshoot this, please get
back to me!!! Thanks again for your brains when mine are lacking!!!!!
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range
'Set prompt
Message = "Enter the number of copies that you want to print"
'Set Title
Title = "Print"
'Set Default
Default = "1"
'Display message, title, and default value
NumCopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\Setting.txt",
"MacroSettings", "SerialNumber")
If SerialNumber = "" Then
SerialNumber = 1
End If
Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0
While Counter < NumCopies
Rng1.Delete
Rng1.Text = Format(SerialNumber, "00#")
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
Counter = Counter + 1
Wend
'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Settings.txt", "MacroSettings",
"SerialNumber") = SerialNumber
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With
ActiveDocument.Save
End Function
End Function
Is that why it's not working in Excel? It bombs on the "SerialNumber =
System.PrivateProfileString("C:\Setting.txt", "MacroSettings",
"SerialNumber")" line. It doesn't go any further than that, so I don't know
if it will work past that, either. If there's anything here that you think
wouldn't work in Excel or any tips on how to troubleshoot this, please get
back to me!!! Thanks again for your brains when mine are lacking!!!!!
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range
'Set prompt
Message = "Enter the number of copies that you want to print"
'Set Title
Title = "Print"
'Set Default
Default = "1"
'Display message, title, and default value
NumCopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\Setting.txt",
"MacroSettings", "SerialNumber")
If SerialNumber = "" Then
SerialNumber = 1
End If
Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0
While Counter < NumCopies
Rng1.Delete
Rng1.Text = Format(SerialNumber, "00#")
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
Counter = Counter + 1
Wend
'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Settings.txt", "MacroSettings",
"SerialNumber") = SerialNumber
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With
ActiveDocument.Save
End Function
End Function