T
Torsten Hansen
Hello again,
I had a similar problem with the orientation on landscape. When I've put a
picture from the clipboard into my new word document the cursor appears in
the first row of the document.
Then I make a page break and now I want to set the cursor in the first line
of the second page. This works in a word macro with "Selection.MoveDown...",
but when I accomplish the makro from Excel, Access... the command doesn't
work.
Can anybody give me an advice?
Sub Test_Makro_From_Excel()
Dim WordObj As Object
Dim WordDoc As Object
'copy anything to the excel-clipboard
Range("B58").Select
Selection.Copy
On Error Resume Next
Set WordObj = GetObject(, "Word.Application.10")
If Err.Number = 429 Then
Set WordObj = CreateObject("Word.Application.10")
Err.Number = 0
End If
WordObj.Visible = True
Set WordDoc = WordObj.Documents.Add
With WordObj
.Selection.PasteSpecial DataType:=3 'insert as picture
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.InsertBreak Type:=1
.ActiveDocument.Shapes("Picture 2").Select
.Selection.ShapeRange.ScaleWidth 1.52, msoFalse, msoScaleFromTopLeft
.Selection.ShapeRange.ScaleHeight 1.52, msoFalse, msoScaleFromTopLeft
.Selection.ShapeRange.ScaleHeight 1.32, msoFalse, msoScaleFromTopLeft
.ActiveWindow.ActivePane.VerticalPercentScrolled = 0
.ActiveWindow.ActivePane.VerticalPercentScrolled = 32
.Selection.ShapeRange.IncrementTop 9#
.Selection.Collapse
'this command doesn't work from Excel, Access...
!!!!!!!!!!!!!!!!!!!!!!!
.Selection.MoveDown Unit:=wdLine, Count:=22
End With
Set WordDoc = Nothing
Set WordObj = Nothing
End Sub
Many Thanks!
Torsten
I had a similar problem with the orientation on landscape. When I've put a
picture from the clipboard into my new word document the cursor appears in
the first row of the document.
Then I make a page break and now I want to set the cursor in the first line
of the second page. This works in a word macro with "Selection.MoveDown...",
but when I accomplish the makro from Excel, Access... the command doesn't
work.
Can anybody give me an advice?
Sub Test_Makro_From_Excel()
Dim WordObj As Object
Dim WordDoc As Object
'copy anything to the excel-clipboard
Range("B58").Select
Selection.Copy
On Error Resume Next
Set WordObj = GetObject(, "Word.Application.10")
If Err.Number = 429 Then
Set WordObj = CreateObject("Word.Application.10")
Err.Number = 0
End If
WordObj.Visible = True
Set WordDoc = WordObj.Documents.Add
With WordObj
.Selection.PasteSpecial DataType:=3 'insert as picture
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.InsertBreak Type:=1
.ActiveDocument.Shapes("Picture 2").Select
.Selection.ShapeRange.ScaleWidth 1.52, msoFalse, msoScaleFromTopLeft
.Selection.ShapeRange.ScaleHeight 1.52, msoFalse, msoScaleFromTopLeft
.Selection.ShapeRange.ScaleHeight 1.32, msoFalse, msoScaleFromTopLeft
.ActiveWindow.ActivePane.VerticalPercentScrolled = 0
.ActiveWindow.ActivePane.VerticalPercentScrolled = 32
.Selection.ShapeRange.IncrementTop 9#
.Selection.Collapse
'this command doesn't work from Excel, Access...
!!!!!!!!!!!!!!!!!!!!!!!
.Selection.MoveDown Unit:=wdLine, Count:=22
End With
Set WordDoc = Nothing
Set WordObj = Nothing
End Sub
Many Thanks!
Torsten