-
Solved: Pagination problems
This is XL VBA but essentially a Word problem. I've been using a variation of the following XL VBA code to control Word's pagination. I need Word's pagination turned on for other XL VBA code to work, but I want to return the user's Word pagination setting to its' original state following the completion of the other XL VBA code. My previous testing indicated that it worked as desired but now I find that when I go to ANY Word document that the background repagination checkbox is checked but the entire option is greyed out and no longer accessible (Open Word doc, tools/options/general to see background repagination). The following XL VBA code is similiar to what I'm using and is just designed to test this problem. My testing indicates that the pagination is indeed being changed but the option remains checked and greyed out whether pagination is on or off. Have I broke something? Perhaps setting pagination to false is actually removing it as an accessible option? Dave
ps. need "C\testit.doc" to test code
[VBA]
Sub PagTest()
Dim Wapp As Object, PagFlag As Boolean, Temp As String
On Error GoTo ErFix
'Open file
Set Wapp = CreateObject("Word.Application")
Temp = "c:\Testit.doc"
Wapp.documents.Open Filename:=Temp, ReadOnly:=True
MsgBox "Start Pagination is: " & Wapp.Options.Pagination
'change pagination
If Wapp.Options.Pagination = False Then
Wapp.Options.Pagination = True
PagFlag = True
Else
Wapp.Options.Pagination = False
PagFlag = False
End If
MsgBox "Changed Pagination is: " & Wapp.Options.Pagination
'return pagination to original setting
If PagFlag Then
Wapp.Options.Pagination = False
Else
Wapp.Options.Pagination = True
End If
MsgBox "Ending Pagination is: " & Wapp.Options.Pagination
Wapp.Quit
Set Wapp = Nothing
Exit Sub
ErFix:
On Error GoTo 0
If PagFlag Then
Wapp.Options.Pagination = False
Else
Wapp.Options.Pagination = True
End If
Wapp.Quit
Set Wapp = Nothing
End Sub
[/VBA]
-
how about something like:
[vba] Wapp.Options.Pagination = not Wapp.Options.Pagination
if Wapp.Options.Pagination <> true Then
PagFlag = False
Else
Wapp.Options.Pagination = true
PagFlag = True
End If
[/vba]
-Once my PC stopped working, so I kicked it......Then it started working again
-
Thanks OTWarrior for the help. I get the same result using the "NOT" as setting the option to False but... the option remains checked, greyed out and not accessible. Dave
-
Ummm. You are likely in Print Preview mode. In Print Layout mode, the checkbox is greyed out as inaccessible. Switch to Normal View mode...and voila...it is NOT greyed out, and IS accessible.
It does make sense, in a strange Microsoft kind of way. If you are looking at what print job will be like (essentially how Word paginates, yes?), then your "view" should not be affected by repagination. Unless of course something happens to force one.
Your code, from a code point of view, works fine.
-
[VBA]Wapp.ActiveDocument.ActiveWindow.View.Type = 2[/VBA]
Thanks again Gerry. That was the problem..doh! The above code will set the Word view to normal (3 is preprint). The changes must be saved and viola, as Gerry promised, my background repagination option has returned to normal and is once again accessible. Have a great day! Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules