R
Rich
Hi All,
I have seen this problem on a few forums and have found a solution that has
so far worked 100%. If you don't want all the details skip to the second to
last line.
The problem occurs when using a VBA macro to set certain Page Setup
Properties such as
ActiveDocument.PageSetup.FirstPageTray=1
ActiveDocument.PageSetup.RightMargin=10
On trying this on some documents that contain section breaks an error is
received
Run-time error '4608': Value Out Of Range
The only solutions I could find were to replace all section breaks with page
breaks which in a lot of circumsatnces works fine. But if the section breaks
are necessary then there are ways to correct the document.
After hours of frustration I decided I needed to compare a working document
with a broken document and the only way I could think to do this was to save
it as XML and view it in a text editor. What I found was that there is an
attribute in each section which has the XML of <w:docGrid
w:line-pitch="360"/> or similar this XML can usually be found just before
</w:sectPr>.
Now in a healthy document this setting is the same in each section
throughout the document. And in a document that causes the error the
line-pitch is different in one or more of the sections.
--Note if the setting is present in any one section then it must be the same
value and included in all sections.
There is also a simpler way I have found to correct the documents but I
don't know if the method will have any side effects. You would think that if
the 'line-pitch' was visible in the XML then there would be some where in
Word that you could set this value. However in a normal English word setup
it is impossible to find.
Usually in Word on the Page Setup dialog there are 3 tabs Margins, Paper,
Layout.
But if you go into Start->Programs->Microsoft Office->Microsoft Office
Tools->Microsoft Office 2003 Language Settings and add Korean, Chinese, or
Japanese to the enabled languages you will get an
extra tab called Document Grid and in here you can specify Grid setting.
The normal value for line-pitch seems to be 360 in the XML for (A4 Paper).
To achieve this through the word interface I have been selecting the radio
button 'Specify Line Grid Only' and then setting the Pitch in the lines
setting to 18 (set it to 17 then click the up arrow) make sure to apply to
the whole document and run the VB code again this time no error.
I was just about to ask for some help to achieve this in a macro when it
struck me I can record a macro.
ActiveDocument.PageSetup.LinesPage = 38 'achieves the same as all
the above but is a little bit easier.
Just thought I should share that knowledged with you.
Rich.
I have seen this problem on a few forums and have found a solution that has
so far worked 100%. If you don't want all the details skip to the second to
last line.
The problem occurs when using a VBA macro to set certain Page Setup
Properties such as
ActiveDocument.PageSetup.FirstPageTray=1
ActiveDocument.PageSetup.RightMargin=10
On trying this on some documents that contain section breaks an error is
received
Run-time error '4608': Value Out Of Range
The only solutions I could find were to replace all section breaks with page
breaks which in a lot of circumsatnces works fine. But if the section breaks
are necessary then there are ways to correct the document.
After hours of frustration I decided I needed to compare a working document
with a broken document and the only way I could think to do this was to save
it as XML and view it in a text editor. What I found was that there is an
attribute in each section which has the XML of <w:docGrid
w:line-pitch="360"/> or similar this XML can usually be found just before
</w:sectPr>.
Now in a healthy document this setting is the same in each section
throughout the document. And in a document that causes the error the
line-pitch is different in one or more of the sections.
--Note if the setting is present in any one section then it must be the same
value and included in all sections.
There is also a simpler way I have found to correct the documents but I
don't know if the method will have any side effects. You would think that if
the 'line-pitch' was visible in the XML then there would be some where in
Word that you could set this value. However in a normal English word setup
it is impossible to find.
Usually in Word on the Page Setup dialog there are 3 tabs Margins, Paper,
Layout.
But if you go into Start->Programs->Microsoft Office->Microsoft Office
Tools->Microsoft Office 2003 Language Settings and add Korean, Chinese, or
Japanese to the enabled languages you will get an
extra tab called Document Grid and in here you can specify Grid setting.
The normal value for line-pitch seems to be 360 in the XML for (A4 Paper).
To achieve this through the word interface I have been selecting the radio
button 'Specify Line Grid Only' and then setting the Pitch in the lines
setting to 18 (set it to 17 then click the up arrow) make sure to apply to
the whole document and run the VB code again this time no error.
I was just about to ask for some help to achieve this in a macro when it
struck me I can record a macro.
ActiveDocument.PageSetup.LinesPage = 38 'achieves the same as all
the above but is a little bit easier.
Just thought I should share that knowledged with you.
Rich.