Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2012, 05:32 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default Problems with Watermark


I am trying to open a Microsoft Word document and add a watermark using VBA in Access 2007. The document opens and prints the watermark on all pages but the first page. While debugging the module that does this we have found that once word is opened it refers to the first page as the FirstHeaderPage whereas all other pages are just HeaderFooter. We tried to do the macro recorder within Word to get the code for adding watermarks. The watermark in Word works fine and shows on all pages but when we copy the code to Microsoft Access the first page is still without a watermark. Any help is appreciated.
Reply With Quote
  #2  
Old 05-24-2012, 11:49 PM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi AOsment742,

Every Section in a Word document has three headers: Primary; First page; and Even. Your document is evidently configured with a 'different first page' layout. Your problem description is ambiguous and it's not clear whether you're using:
.Sections.First.Headers(wdHeaderFooterPrimary)
or
.Sections.First.Headers(wdHeaderFooterFirstPage)
but you should be using both.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-25-2012, 05:41 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

We don't appear to be using either of these. To be honest, we know very little about Word. We opened word and recorded the macro to get the vba to add a watermark and we copied this code over to an access module. Like I said earlier, when we added the watermark in Word it was on every page. But when we try to open the document from Access and add the watermark through the module, the first page does not have it. Thanks for your help.
Code:
Set doc = appWord.Parent.Documents.Open(NewDoc, , False, False)
Set doc = appWord.ActiveDocument
appWord.ActiveDocument.Sections(1).Range.Select
doc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
doc.ActiveWindow.Selection.HeaderFooter.Shapes.AddTextEffect( _
PowerPlusWaterMarkObject325783140, FileType, "Arial Narrow", _
38, False, False, 0, 0).Select
doc.ActiveWindow.Selection.ShapeRange.Name = "PowerPlusWaterMarkObject71909250"
doc.ActiveWindow.Selection.ShapeRange.TextEffect.NormalizedHeight = False
doc.ActiveWindow.Selection.ShapeRange.Line.Visible = False
doc.ActiveWindow.Selection.ShapeRange.Fill.Visible = True
doc.ActiveWindow.Selection.ShapeRange.Fill.Solid
doc.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB = RGB(192, 192, 192)
doc.ActiveWindow.Selection.ShapeRange.Fill.Transparency = 0.5
doc.ActiveWindow.Selection.ShapeRange.Rotation = 315
doc.ActiveWindow.Selection.ShapeRange.LockAspectRatio = True
doc.ActiveWindow.Selection.ShapeRange.Height = InchesToPoints(3.29)
doc.ActiveWindow.Selection.ShapeRange.Width = InchesToPoints(6.85)
doc.ActiveWindow.Selection.ShapeRange.WrapFormat.AllowOverlap = True
doc.ActiveWindow.Selection.ShapeRange.WrapFormat.Side = wdWrapNone
doc.ActiveWindow.Selection.ShapeRange.Left = appWord.InchesToPoints(-0.5)
doc.ActiveWindow.Selection.ShapeRange.WrapFormat.Type = 3
doc.ActiveWindow.Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
doc.ActiveWindow.Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
doc.ActiveWindow.Selection.ShapeRange.Top = InchesToPoints(3)
doc.ActiveWindow.Selection.FormattedText.ShowAll = False
doc.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
doc.ActiveWindow.Document.ActiveWindow.View = wdPrintView
doc.ActiveWindow.View.ShowMarkupAreaHighlight = False
doc.ActiveWindow.View.ShowComments = False
doc.ActiveWindow.Document.FormattingShowClear = True
doc.ActiveWindow.View.ShowRevisionsAndComments = False
'Save Document as PDF
doc.ActiveWindow.ActivePane.Application.ActiveDocument.SaveAs FileName:=NewFName, _
FileFormat:=wdFormatPDF
'Close application and document
doc.Application.ActiveDocument.Close False
appWord.Application.Quit
Set appWord = Nothing
Set doc = Nothing

Last edited by macropod; 05-25-2012 at 03:44 PM. Reason: Added code tags
Reply With Quote
  #4  
Old 05-25-2012, 04:46 PM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the following. It adds your watermark to each header in the first Section of the document. I don't know what the 'PowerPlusWaterMarkObject325783140' watermark is, so I can't test with that. Neither can I test the code with your numerous other variables. You'll note I've used a different naming convention for the watermarks, as they can't all have the same name.
Code:
Dim Shp As appWord.Shape, HdFt As appWord.HeaderFooter
Set Doc = appWord.Documents.Add.Open(NewDoc, , False, False)
With Doc
  'Add the watermark to each header in the first Section
  With .Sections.First
    For Each HdFt In .Headers
      Set Shp = HdFt.Shapes.AddTextEffect(PowerPlusWaterMarkObject325783140, _
        FileType, "Arial Narrow", 38, False, False, 0, 0)
      With Shp
        .Name = "PowerPlusWaterMarkObject" & Format(Now, "YYMMDD") & Format(HdFt.Index, "00")
        .TextEffect.NormalizedHeight = False
        .Line.Visible = False
        .Fill.Visible = True
        .Fill.Solid
        .Fill.ForeColor.RGB = RGB(192, 192, 192)
        .Fill.Transparency = 0.5
        .Rotation = 315
        .LockAspectRatio = True
        .Height = InchesToPoints(3.29)
        .Width = InchesToPoints(6.85)
        .WrapFormat.AllowOverlap = True
        .WrapFormat.Side = wdWrapNone
        .Left = appWord.InchesToPoints(-0.5)
        .WrapFormat.Type = 3
        .RelativeHorizontalPosition = wdRelativeVerticalPositionMargin
        .RelativeVerticalPosition = wdRelativeVerticalPositionMargin
        .Top = InchesToPoints(3)
      End With
      .Range.FormattedText.ShowAll = False
    Next
  End With
  With .ActiveWindow.View
    .ShowMarkupAreaHighlight = False
    .ShowComments = False
    .ShowRevisionsAndComments = False
  End With
  .FormattingShowClear = True
  'Save Document as PDF
  .SaveAs FileName:=NewFName, FileFormat:=wdFormatPDF
  'Close application and document
  .Close False
End With
appWord.Quit
Set Shp = Nothing: Set Doc = Nothing: Set appWord = Nothing
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-29-2012, 11:43 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

Thank you very much for your help. I copied your code and pasted it into my module but the watermark still does not show on the very first page of the document.
Reply With Quote
  #6  
Old 05-29-2012, 04:08 PM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Can you attach the first couple of pages of the affected document to a post (delete any sensitive data)? You do this via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-30-2012, 11:09 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

I just created a brand new document in Word 2007 and the watermark was on every page. The documents we are trying to use are procedures created in an older version of Word. There are hundreds of them and none appear to open with the watermark on the first page. I opened a different older document and it worked just fine. Is there some kind of conversion we need to do on the documents? Thanks again for the help!
Attached Files
File Type: doc LockOutTesting.doc (57.0 KB, 20 views)
Reply With Quote
  #8  
Old 05-30-2012, 04:24 PM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your document does indeed have a 'Different first page' layout. Even so, the code I posted should add the watermark to the first page. You can demonstrate it four yourself, by opening your attachment, adding the following code to it (which is just a cut-down version of the code from my previous post), then running the code.
Code:
Sub Test()
Dim Shp As Shape, HdFt As HeaderFooter
With ActiveDocument
  'Add the watermark to each header in the first Section
  With .Sections.First
    For Each HdFt In .Headers
      Set Shp = HdFt.Shapes.AddTextEffect(msoTextEffect1, _
        "FileType", "Arial Narrow", 38, False, False, 0, 0)
      With Shp
        .Name = "PowerPlusWaterMarkObject" & Format(Now, "YYMMDD") & Format(HdFt.Index, "00")
        .TextEffect.NormalizedHeight = False
        .Line.Visible = False
        .Fill.Visible = True
        .Fill.Solid
        .Fill.ForeColor.RGB = RGB(192, 192, 192)
        .Fill.Transparency = 0.5
        .Rotation = 315
        .LockAspectRatio = True
        .Height = InchesToPoints(3.29)
        .Width = InchesToPoints(6.85)
        .WrapFormat.AllowOverlap = True
        .WrapFormat.Side = wdWrapNone
        .Left = InchesToPoints(-0.5)
        .WrapFormat.Type = 3
        .RelativeHorizontalPosition = wdRelativeVerticalPositionMargin
        .RelativeVerticalPosition = wdRelativeVerticalPositionMargin
        .Top = InchesToPoints(3)
      End With
      .Range.FormattedText.ShowAll = False
    Next
  End With
  With .ActiveWindow.View
    .ShowMarkupAreaHighlight = False
    .ShowComments = False
    .ShowRevisionsAndComments = False
  End With
  .FormattingShowClear = True
End With
Set Shp = Nothing
End Sub
The fact you're not getting the expected result suggests your 'NewDoc' might already have a second-page watermark and there is a problem with the reference to either:
• PowerPlusWaterMarkObject325783140; or
• FileType
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 05-31-2012, 10:50 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

The PowerPlusWaterMarkObject325783140 came from Word when we recorded a macro to add a watermark. What I read in help files is that Word assigns a unique number coding to each watermark when they are added.
FileType is just a variable in which we pass the word "Active" or "InActive" as the text for the watermark.

So I tried:
I opened my attached document, created a new macro named Test and copied the above code into it. When I run the macro the watermark only shows on page 2 of this document. (Not sure if the OS makes a difference but I tried it on my XP and Windows 7 machine.)
Also, I did try just opening the document and going to the 'Page Layout' tab and adding a watermark manually and it does show on every page.
I also tried to record the macro again from Word by doing the same as just stated - going to the Page Layout tab. I took that code and copied to my Access module and I get the same results - does not show on the first page.
Thanks for all your help! I'll keep trying....
Reply With Quote
  #10  
Old 05-31-2012, 03:42 PM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi AOsment742,

What you say seems strange. Try the attached - it's a copy of your document with the macro from my last post. When I run the 'Test' macro, a watermark is placed on both pages. What happens when you run it?
Attached Files
File Type: doc LockOutTesting.doc (70.5 KB, 30 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 06-01-2012, 05:41 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

I opened the document, ran the macro and saved the document. This is what I get.
Attached Files
File Type: doc LockOutTestingWM.doc (71.5 KB, 11 views)
Reply With Quote
  #12  
Old 06-01-2012, 06:12 AM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That suggests there's something faulty in your Word installation. Try repairing Word (Word Options|Resources|Diagnose).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 06-07-2012, 08:13 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

I have found that if I click on the Header of the first page and go to it's Design tab, there is an option checked - 'Different First Page'. I unchecked this and the macro to add the watermark works on all pages.
Reply With Quote
  #14  
Old 06-07-2012, 03:50 PM
macropod's Avatar
macropod macropod is offline Problems with Watermark Windows 7 64bit Problems with Watermark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi AOsment742,

Sure, that will work, but the whole point of the re-coding that I did is to ensure the watermark gets applied to all pages regardless of whether you have the 'different first page' or 'different odd and even' options checked. That the macro doesn't work as advertised on your system suggests you have an underlying issue with your Word installation. That's why I suggested that you try repairing Word.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 06-08-2012, 07:20 AM
AOsment742 AOsment742 is offline Problems with Watermark Windows XP Problems with Watermark Office 2007
Novice
Problems with Watermark
 
Join Date: May 2012
Posts: 8
AOsment742 is on a distinguished road
Default

I did try the repair in Word but I work in the manufacturing world so our computers are imaged by the corporate help desk and therefore can't really question their installation. I had many people within our plant try the macro and all had the same result so fixing my installation wasn't going to solve the other hundreds that will be running our application. I started looking at other documents and I found that those documents without the different header on the first page worked just fine. I took the above document and deleted the header part on the first page and it worked. These documents were created years ago and we have hundreds of them. All of them have the same kind of different header on the first page. Again, I know very little about Word and I may have found a temporary fix for the problem. Thanks again for all your help.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Watermark Background/watermark won't go away Lea Word 6 04-07-2014 08:59 AM
Problems with Watermark Watermark deletes headers ChrisDevrell Word 1 05-01-2012 07:23 AM
Problems with Watermark Word watermark jonmac29 Word 3 04-26-2011 04:43 AM
Problems with Watermark Watermark saslotteroy Word 1 04-12-2011 03:52 AM
watermark issues kknutson Word 0 03-19-2007 10:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft