I have a multi-step process in Excel that needs to be reported to a Word file.
Each step has a characteristic graphic icon, which is to be followed by text reporting parameters for that step.
The data and graphic details are read from arrays sequentially, so I think the Word doc should grow by appendation.
So the layout would be:
Step A Graphic (say 40x40 in size)
Step A parameters .....
Step B Graphic (say 40x40 in size)
Step B parameters .....
Though I will need to use Excel in early binding with MW Word to create the Word report, at present I'm concentrating on using Word vba ALONE to place graphics in a word file, and I'm finding difficulties.
For Text, I'm using FileSystemObject.TextStrea
m.Write with vba in excel and writing to a doc file:
Dim fso As New FileSystemObject
Dim stream As TextStream
Set stream = fso.OpenTextFile("c:\tstTe
", 8, TristateFalse) 'where 8 = ForAppending ...
stream.Write "This line uses the Write method nov20." '.... and appends this text
For Graphic, (using vba in word right now) I have got the following, which I've run after simply clicking the word page to which the graphic is to be sent:
Dim shp As Shape
Set shp = ActiveDocument.Shapes.AddP
eName, msoFalse, msoTrue)
However, though i have code to size, crop, and position the graphic, I these parameters interact and make it difficult to work out how they work, or even whether I've selected the right starting points:
.PictureOffsetX = 15 'picWidth / 10
.PictureOffsetY = 16 'picHeight / 10
.PictureHeight = picHeight * 0.5
.PictureWidth = picWidth * 0.5
' Now modify the cropping by changing the shape of the container. Changing the shape alters
' the portion of the picture that you see:
.ShapeHeight = 140
.ShapeWidth = 140
.ShapeLeft = 110
.ShapeTop = 120
(sourced from: https://code.msdn.microsoft.com/office/Word-2010-Add-Picture-ddb5c728
My first Question is: Have I selected the right methods for text and graphic, and can you help me with the principles of placing graphics (sized) at the right point in text? Issues such as text margins and font size can follow later.
I hope you can help me!