Visual Studio Development Bookmark and Share   
 index > Visual Studio Tools for Office > Why cant i create a Watermark in an Word 2007 Document out of vb.net?
 

Why cant i create a Watermark in an Word 2007 Document out of vb.net?

Hi,

i wrote a word Addin which should insert a Watermark as Text-Shape in the header of my Document. This is my Code:

        Dim wApp As word.Application = Globals.ThisAddIn.Application
        Dim wDoc As word.Document = wApp.ActiveDocument               
		With wDoc.Sections(1).Headers(word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Shapes
                    With .AddTextEffect(MsoPresetTextEffect.msoTextEffect1, Text:=txtWasserzeichen.Text, FontName:="Arial Black", FontSize:=28, FontBold:=MsoTriState.msoTrue, FontItalic:=MsoTriState.msoFalse, Left:=0, Top:=0, Anchor:=wDoc.Sections(1).Headers(word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range)
                        ' Nachträglich von mir hinzugefügt. Hat das einen Effekt?
                        .TextEffect.Alignment = MsoTextEffectAlignment.msoTextEffectAlignmentCentered

                        .RelativeVerticalPosition = word.WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin
                        .RelativeHorizontalPosition = word.WdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin

                        .Left = word.WdShapePosition.wdShapeCenter
                        .Top = word.WdShapePosition.wdShapeCenter

                        .Rotation = -45
                        .Name = "Wasserzeichen"

                        .Fill.Visible = MsoTriState.msoTrue
                        .Fill.Solid()
                        .Fill.ForeColor.RGB = RGB(200, 200, 200)
                        .Fill.Transparency = 0.5
                        .Line.Weight = 0.75
                        .Line.DashStyle = MsoLineDashStyle.msoLineSolid
                        .Line.Style = MsoLineStyle.msoLineSingle
                        .Line.Transparency = 0.0#
                        .Line.Visible = MsoTriState.msoFalse
                        .LockAspectRatio = MsoTriState.msoFalse
                        '.LockAnchor = False
                    End With
                End With
But i dont get any errors and no text is displayed. Whats wrong with my code? Can someone perhaps test it?

regards
bc
bcinc.  Sunday, October 18, 2009 11:17 AM
  • Marked As Answer bybcinc. Sunday, October 18, 2009 2:44 PM
  •  
Jose Anton Bautista  Sunday, October 18, 2009 11:46 AM
  • Marked As Answer bybcinc. Sunday, October 18, 2009 2:44 PM
  •  
Jose Anton Bautista  Sunday, October 18, 2009 11:46 AM

You can use google to search for other answers

Custom Search

More Threads

• Setup&Deployment Question
• Action Panel, MS Word and database access
• "Office document customization is not available" error
• How to find Range of Selected Content in Non-Active Document?
• Upgarde the managed code from Infopath 2003 to infopath 2007
• VS 2008 ClickOnce Deployment for Office 2007
• VSTO 2005
• Password and CopyObject method to copy modules in AccessDB
• Outlook Calendar events
• Load Behavior Changes to 0 of Word Add-In