PDA

View Full Version : Word VBA to hide first page of .htm Word document



joshuap2005
02-05-2015, 07:49 PM
Thank you in advance for any help you can offer. I am not very proficient with VBA for Word (I prefer Excel) and am having some issues with a project I am working on.

At work we have information on how to do various jobs. That information is on Word and the first page involves a Job Description which is a set format with various details on the requirements for the person doing the task. The remaining pages are the actual Job Procedure which details how to do the job.

We have the following goals/requirements:
1. We want these word documents to be viewed as .html/.htm files but we do not want the actual Job Description page (page 1) seen when viewed as html (although we want a way to view this page whenever we update the procedures or requirements or are looking at assigning this job to someone else).
2. We want to keep these documents as something we can edit in Word so we do not need to contact IT every time we want to update these procedures.
3. We have three objects (a logo of our company, a dark teal banner/shape, and another picture) that need to be displayed at the top of the “Job Procedures” page (page 2). The logo and the other picture would not have text in front of or behind it. However, the dark teal banner/picture will have white text that states “Customer Service Job Procedure” in front of it.

I have created a Word document and saved it as a .htm file. I have also included a bookmark at the beginning of the Job Procedure page. I have created a macro that hides or unhides the range(0,start of bookmark). To use this macro, you have to edit the document in Word (so those that are viewing this on their browsers will not see this option). However, I am having the following issues:
1. When editing in Word, the teal banner/shape (“Rectangle 5”) always stays near the top of the Job Description section on page 1 (whether or not the first page is hidden) and is behind the text (at least I assume it stays at the top as when I hide page 1 the shape disappears so I assume it is being hidden alone with page 1). However, when I save the document (whether or not I save it with the first page hidden or unhidden) and then view the file as a webpage, the shape shows up at the top of the webpage (so if the first page is unhidden when saved, the shape is over the Job Descriptions page and if the first page is hidden when saved, the shape is over the Job Procedures page).

I want this shape to display on page 2 behind the “Customer Service Job Procedure” text instead whether I am editing the document in Word or viewing the file as a webpage. However, if the fact that it isn’t showing up in the right place when I edit the document and isn’t moving to the right space when saved as a webpage was the only issue, that would be fine (I could just have the macro hide the shape when I unhide the first page so it doesn’t look funky by appearing at the top of page 1 and we don’t plan to save the file with the first page unhidden anyway). However…

2. Although the Rectangle 5 shape displays behind the text when editing the document in Word, every time I view the document as a web page, the shape covers up the text. I need to somehow get this shape to show up behind the text when viewed as a webpage.

Any help would be much appreciated. I included the file here as well (I had to attach is as a .docx file as it wouldn't let me upload it as a .htm file).12825

gmayor
02-07-2015, 12:43 AM
Word document formats and html format are very different. For a start HTML doesn't support pages, header footers etc., and it lays out graphics differently. You instantly get the idea is you select Word's web view. You need to create the document for the Web view to have any hope of achieving your aims, or create separate versions for Word and HTML.

Have you considered using PDF format?