Word setting by using macros for printing copy

Hi,
A customer letter is written als word file. This file contents a macro that will be automatically activated by printhng the original letter and starts the following steps:
1) prepare the printing of a letter copy
2) cover the text field showing  the adressee of the original letter with a text field showing the adressee of the copy letter.

This process runs without any problems by many users. They write the original letter. The addressee of the letter copy will be given to the macro als parameter. The users print the original letter and the letter copy will automatically printed with the addressee of the copy in the right letter position.

By one user the text field "addressee of the original letter" will not be covered by the text field "addressee of letter copy" but only pulled down. Therefore you have 2 adressees on the print of the letter copy.

How can I change the word settings of this user without changing the ones of the other users? Or can I change anything directly in the macro code making sure that the text fields have a definite position on the document?

Please find attached the macro code.

Many thanks in advance and have a nice day!

isaf


Sub Wasserzeichen(bolStandard As Boolean)
 
Dim bolGesperrt As Boolean
bolGesperrt = False
 
  If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
        ActiveDocument.Unprotect
        bolGesperrt = True
   End If
 
 
ActiveDocument.Bookmarks.Add "_InMacro_"
 
Selection.HomeKey Unit:=wdStory
 
 
If bolStandard Then
    Application.PrintOut
Else
    With Dialogs(wdDialogFilePrint)
    .Show
    End With
End If
 
'Start hier
If ActiveDocument.CustomDocumentProperties("VM_OriginalBrief") = "False" Then
    
    Dim strVermittlerNamenAdresse As String
    strVermittlerNamenAdresse = "Adressee of letter copy"
    
    
    Dim objShape2 As Word.Shape
    Set objShape2 = ActiveDocument.Shapes.AddTextbox( _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=10, _
    Top:=10, _
    Width:=10, _
    Height:=10, _
    Anchor:=Selection.Paragraphs(1).Range)
 
    With objShape2
    .LockAnchor = True
 
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
 
    .LockAspectRatio = False
    .Top = CentimetersToPoints(5)
    .Left = CentimetersToPoints(2)
    .Width = CentimetersToPoints(12)
    .Height = CentimetersToPoints(3.5)
    
    
    .Line.ForeColor.RGB = RGB(255, 255, 255)
    .Line.BackColor.RGB = RGB(255, 255, 255)
    
    
    .TextFrame.TextRange.Font.Name = "Arial"
    .TextFrame.TextRange.Font.Size = 12
 
    
    .TextFrame.TextRange.Text = strVermittlerNamenAdresse
    
    End With
    
    'does not concern the problem
    Dim strText As String
    Dim strEmpfaengerNamenOriginal As String
    
    If ActiveDocument.CustomDocumentProperties("Schreiben_an") = "AN" Then
        strEmpfaengerNamenOriginal = ActiveDocument.CustomDocumentProperties("Ausfertigung_KopieName")
        strText = "Diese Ausfertigung für die versicherte Person" + vbCrLf + "wurde gesendet an: " + strEmpfaengerNamenOriginal '+ "."
    ElseIf ActiveDocument.CustomDocumentProperties("Schreiben_an") = "Hinterbliebene" Then
        strEmpfaengerNamenOriginal = ActiveDocument.CustomDocumentProperties("Ausfertigung_KopieName")
        strText = "Diese Ausfertigung für die hinterbliebene Person" + vbCrLf + "wurde gesendet an: " + strEmpfaengerNamenOriginal '+ "."
    Else
        strEmpfaengerNamenOriginal = ActiveDocument.CustomDocumentProperties("Original_KopieName")
        strText = "Das Original wurde gesendet an:" + vbCrLf + strEmpfaengerNamenOriginal '+ "."
    End If
    
    
    Dim objShape3 As Word.Shape
    Set objShape3 = ActiveDocument.Shapes.AddTextbox( _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=10, _
    Top:=10, _
    Width:=10, _
    Height:=10, _
    Anchor:=Selection.Paragraphs(1).Range)
 
    With objShape3
    .LockAnchor = True
 
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
 
    .LockAspectRatio = False
    .Top = CentimetersToPoints(0.8)
    .Left = CentimetersToPoints(10)
    .Width = CentimetersToPoints(10)
    .Height = CentimetersToPoints(2.3)
    
    
    .Line.ForeColor.RGB = RGB(255, 255, 255)
    .Line.BackColor.RGB = RGB(255, 255, 255)
    
    
    .TextFrame.TextRange.Font.Name = "Arial"
    .TextFrame.TextRange.Font.Bold = True
    .TextFrame.TextRange.Font.Size = 11
 
    
    .TextFrame.TextRange.Text = strText
    
    .Visible = msoTrue
        
    End With
    
    
    Application.PrintOut
    
End If
 
 
 
 
 Do
  Loop While (ActiveDocument.Undo = True) _
       And ActiveDocument.Bookmarks.Exists("_InMacro_")
 
 
 
If bolGesperrt Then
    If ActiveDocument.ProtectionType = wdNoProtection Then
           
            ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    End If
End If
 
 
End Sub
 
Sub DateiDruckenStandard()
  Wasserzeichen True
End Sub
 
Sub DateiDrucken()
 Wasserzeichen False
End Sub
 
 
 
 
 
 
 
 
Sub Wasserzeichen(bolStandard As Boolean)
 
Dim bolGesperrt As Boolean
bolGesperrt = False
 
  If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
        ActiveDocument.Unprotect
        bolGesperrt = True
   End If
 
 
ActiveDocument.Bookmarks.Add "_InMacro_"
 
Selection.HomeKey Unit:=wdStory
 
 
If bolStandard Then
    Application.PrintOut
Else
    With Dialogs(wdDialogFilePrint)
    .Show
    End With
End If
 
'Start hier
If ActiveDocument.CustomDocumentProperties("VM_OriginalBrief") = "False" Then
    
    Dim strVermittlerNamenAdresse As String
    strVermittlerNamenAdresse = "Adressee of letter copy"
    
    
    Dim objShape2 As Word.Shape
    Set objShape2 = ActiveDocument.Shapes.AddTextbox( _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=10, _
    Top:=10, _
    Width:=10, _
    Height:=10, _
    Anchor:=Selection.Paragraphs(1).Range)
 
    With objShape2
    .LockAnchor = True
 
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
 
    .LockAspectRatio = False
    .Top = CentimetersToPoints(5)
    .Left = CentimetersToPoints(2)
    .Width = CentimetersToPoints(12)
    .Height = CentimetersToPoints(3.5)
    
    
    .Line.ForeColor.RGB = RGB(255, 255, 255)
    .Line.BackColor.RGB = RGB(255, 255, 255)
    
    
    .TextFrame.TextRange.Font.Name = "Arial"
    .TextFrame.TextRange.Font.Size = 12
 
    
    .TextFrame.TextRange.Text = strVermittlerNamenAdresse
    
    End With
    
    'does not concern the problem
    Dim strText As String
    Dim strEmpfaengerNamenOriginal As String
    
    If ActiveDocument.CustomDocumentProperties("Schreiben_an") = "AN" Then
        strEmpfaengerNamenOriginal = ActiveDocument.CustomDocumentProperties("Ausfertigung_KopieName")
        strText = "Diese Ausfertigung für die versicherte Person" + vbCrLf + "wurde gesendet an: " + strEmpfaengerNamenOriginal '+ "."
    ElseIf ActiveDocument.CustomDocumentProperties("Schreiben_an") = "Hinterbliebene" Then
        strEmpfaengerNamenOriginal = ActiveDocument.CustomDocumentProperties("Ausfertigung_KopieName")
        strText = "Diese Ausfertigung für die hinterbliebene Person" + vbCrLf + "wurde gesendet an: " + strEmpfaengerNamenOriginal '+ "."
    Else
        strEmpfaengerNamenOriginal = ActiveDocument.CustomDocumentProperties("Original_KopieName")
        strText = "Das Original wurde gesendet an:" + vbCrLf + strEmpfaengerNamenOriginal '+ "."
    End If
    
    
    Dim objShape3 As Word.Shape
    Set objShape3 = ActiveDocument.Shapes.AddTextbox( _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=10, _
    Top:=10, _
    Width:=10, _
    Height:=10, _
    Anchor:=Selection.Paragraphs(1).Range)
 
    With objShape3
    .LockAnchor = True
 
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
 
    .LockAspectRatio = False
    .Top = CentimetersToPoints(0.8)
    .Left = CentimetersToPoints(10)
    .Width = CentimetersToPoints(10)
    .Height = CentimetersToPoints(2.3)
    
    
    .Line.ForeColor.RGB = RGB(255, 255, 255)
    .Line.BackColor.RGB = RGB(255, 255, 255)
    
    
    .TextFrame.TextRange.Font.Name = "Arial"
    .TextFrame.TextRange.Font.Bold = True
    .TextFrame.TextRange.Font.Size = 11
 
    
    .TextFrame.TextRange.Text = strText
    
    .Visible = msoTrue
        
    End With
    
    
    Application.PrintOut
    
End If
 
 
 
 
 Do
  Loop While (ActiveDocument.Undo = True) _
       And ActiveDocument.Bookmarks.Exists("_InMacro_")
 
 
 
If bolGesperrt Then
    If ActiveDocument.ProtectionType = wdNoProtection Then
           
            ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    End If
End If
 
 
End Sub
 
Sub DateiDruckenStandard()
  Wasserzeichen True
End Sub
 
Sub DateiDrucken()
 Wasserzeichen False
End Sub

Open in new window

example.doc
inversojvoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joanne M. OrzechManager, Document Services CenterCommented:
Rather than "covering" the address, why don't you just programatically mark the text as Hidden?  Format, Font, Hidden.
0
inversojvoAuthor Commented:
Hi,

What do you mean exactly?

I have a problem. This letter will be generated through access. Access uses other patterns with variables for putting the addressee of the original letter to the right position on the letter. (A developper of another company implemented this. I do not have any possibilities to change this code and to influence the position of the text for the addressee of the original letter.

Do I have the possibility for the text field (objShape2 in code) for the address of the letter copy to chose the option "in front of the text" (see attached file) e.g. by changing the code 93 and 94 with something like: .wdTaskPaneRevealFormatting.Visible = True
or with something like
ObjShape2.TextFrame = wd....?

Can I find on the web some information (code) to influence the properties of a text field?

Many thanks and have a nice day!
isaf
Code.doc
0
Joanne M. OrzechManager, Document Services CenterCommented:
Is it currently set to "Inline with text"?
0
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Joanne M. OrzechManager, Document Services CenterCommented:
This should take the first inline shape in your document and set it to in front of text..
Sub SetInFront()
Dim ObjShape2 As Shape
 
Set ObjShape2 = ActiveDocument.InlineShapes(1).ConvertToShape
End Sub

Open in new window

0
inversojvoAuthor Commented:
Hi JOrzech,

Many thanks for your help!

May I ask you what this code means? What should it change?

I would add the following code at the line 43
   
    .WrapFormat.AllowOverlap = True
    .WrapFormat.Side = wdWrapBoth

Would it change anything when I set   .LockAnchor = True to   .LockAnchor = false?

Sorry but I do not know so much about vba for word.

Many thanks and have a nice day!
isaf
0
Joanne M. OrzechManager, Document Services CenterCommented:
There is only one line of code there that does anything...which is:
Set ObjShape2 = ActiveDocument.InlineShapes(1).ConvertToShape

It simply takes the first inline shape in your document and converts it to be in front of text.

Before adding or changing anything... at least try to just run the code I posted and make sure it works the way you want it to.  Then you can fine tune it isaf.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joanne M. OrzechManager, Document Services CenterCommented:
Thank you.  I'm glad I could help....

Joanne Orzech
MS Word MVP
EE Zone Advisor
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.