I'm working on a project in Access that uses Word to print a report that contains fields with rich text. The rich text file is being created dynamically by combining the content from each of the fields and reformatting the rtf codes accordingly.
Since the rtf document is being created dynamically, I've also created two subroutines to store and retrieve page setup options to / from a .ini file for printing. It all seems logical enough until I try to manipulate the Orientation property of the PageSetup object from the saved settings.
Here's the routine logic:
1. I create a Word.Application object using late binding
2. I create a document object by opening the RTF document in word using the Documents.Open() method of the word object
3. I open/read the pagesetup.ini file and apply the settings to each section of the document object
4. I display the RTF document in the printpreview mode in word by setting the word properties Visible=True and PrintPreview = True
5. I display the word page setup dialog using the Dialogs(178).Show method of the word object
6. I loop with a DoEvents in Access while the PrintPreview property of the word object = True
7. Finally, I save each of the pagesetup properties of the document object back to the pagesetup.ini file to reflect any chages made by the user
Now, everything works as expected until you try to preview, setup, or print based on the saved options. Step #2 above uses a subroutine which is called with the document object passed by reference (ByRef) to apply the 28 saved settings. All but 6 of the settings are applied successfully. The remaining 6 all appear to relate to orientation (portrait / landscape), which are not applied and no error is produced. These are the settings:
TopMargin, BottomMargin, RightMargin, LeftMargin, Orientation, PaperSize
The margin settings just appear to be switched based on the orientation, being Top / Bottom now reflect Right / Left values and vice-versa. The Orientation and PaperSize settings seem to directly influence each other.
I've tried applying the settings to the document object, to each section object of the document, applying the Orientation first / last. All to no avail.
Has anyone (who is still reading this long post) ever run into this type of problem with the Orientation property? I'm beating my head against a wall, and the Motrin is wearing off, so any help would be extremely appreciated.
- Glen
Know thy data.
Since the rtf document is being created dynamically, I've also created two subroutines to store and retrieve page setup options to / from a .ini file for printing. It all seems logical enough until I try to manipulate the Orientation property of the PageSetup object from the saved settings.
Here's the routine logic:
1. I create a Word.Application object using late binding
2. I create a document object by opening the RTF document in word using the Documents.Open() method of the word object
3. I open/read the pagesetup.ini file and apply the settings to each section of the document object
4. I display the RTF document in the printpreview mode in word by setting the word properties Visible=True and PrintPreview = True
5. I display the word page setup dialog using the Dialogs(178).Show method of the word object
6. I loop with a DoEvents in Access while the PrintPreview property of the word object = True
7. Finally, I save each of the pagesetup properties of the document object back to the pagesetup.ini file to reflect any chages made by the user
Now, everything works as expected until you try to preview, setup, or print based on the saved options. Step #2 above uses a subroutine which is called with the document object passed by reference (ByRef) to apply the 28 saved settings. All but 6 of the settings are applied successfully. The remaining 6 all appear to relate to orientation (portrait / landscape), which are not applied and no error is produced. These are the settings:
TopMargin, BottomMargin, RightMargin, LeftMargin, Orientation, PaperSize
The margin settings just appear to be switched based on the orientation, being Top / Bottom now reflect Right / Left values and vice-versa. The Orientation and PaperSize settings seem to directly influence each other.
I've tried applying the settings to the document object, to each section object of the document, applying the Orientation first / last. All to no avail.
Has anyone (who is still reading this long post) ever run into this type of problem with the Orientation property? I'm beating my head against a wall, and the Motrin is wearing off, so any help would be extremely appreciated.
- Glen
Know thy data.