B
bryan
I have inserted documents into templates with macros and have come across a
new one.
The doc I want to insert is in landscape.
How can I change the orientation and then change back after inserting the
file.
Here is my macro:
Sub HOCheck3()
If ActiveDocument.FormFields("HOC3").CheckBox.Value = True Then
If ILchk = 0 Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
myDoc.Unprotect
Set docrange = myDoc.Range
With docrange
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
.Collapse wdCollapseEnd
.InsertFile "U:\HO Inventory List.doc"
End With
myDoc.Protect wdAllowOnlyFormFields, NoReset
If strFW <> "" Then
Dim bmRange As Range
Set bmRange = ActiveDocument.Bookmarks("ILFW").Range
ActiveDocument.AttachedTemplate.AutoTextEntries(strFW).Insert
WHERE:=bmRange, RichText:=True
ActiveDocument.Bookmarks.Add _
Name:="ILFW", _
Range:=bmRange
End If
'
With ActiveDocument
ActiveDocument.Unprotect
.FormFields("HideP1").Range.Paragraphs(1).Range.Font.Hidden = False
.FormFields("HOC3").Range.Paragraphs(1).Range.Font.Hidden = False
ActiveWindow.View.ShowHiddenText = True
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset
End With
ILchk = ILchk + 1
Call UpdRef
Else
End If
End If
End Sub
Thanks,
Bryan
new one.
The doc I want to insert is in landscape.
How can I change the orientation and then change back after inserting the
file.
Here is my macro:
Sub HOCheck3()
If ActiveDocument.FormFields("HOC3").CheckBox.Value = True Then
If ILchk = 0 Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
myDoc.Unprotect
Set docrange = myDoc.Range
With docrange
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
.Collapse wdCollapseEnd
.InsertFile "U:\HO Inventory List.doc"
End With
myDoc.Protect wdAllowOnlyFormFields, NoReset
If strFW <> "" Then
Dim bmRange As Range
Set bmRange = ActiveDocument.Bookmarks("ILFW").Range
ActiveDocument.AttachedTemplate.AutoTextEntries(strFW).Insert
WHERE:=bmRange, RichText:=True
ActiveDocument.Bookmarks.Add _
Name:="ILFW", _
Range:=bmRange
End If
'
With ActiveDocument
ActiveDocument.Unprotect
.FormFields("HideP1").Range.Paragraphs(1).Range.Font.Hidden = False
.FormFields("HOC3").Range.Paragraphs(1).Range.Font.Hidden = False
ActiveWindow.View.ShowHiddenText = True
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset
End With
ILchk = ILchk + 1
Call UpdRef
Else
End If
End If
End Sub
Thanks,
Bryan