Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a picture ina textbox in MSWord

Status
Not open for further replies.

webmonger

Programmer
Mar 13, 2004
66
AU
I have attempted to get appropriate code using the VB Editor and a macro in Word
I was able to get a macro to
insert a picture and a macro to insert a textbox

I was unable to make one to insert a textbox and insert a picture inside it.

I tried this code in VFP6 without success

Code:
	newTextbox = loWord.Shapes.AddTextbox(0,100,100,100.100)
with newTextbox
objPicture = .InlineShapes.AddPicture(mywholepict , .F., .T.)
endwith

Can anyone offer a way?

Has anyone got a URL for the parameters of a picture object like .ht for example?

Thanks
Webber
 
Hi Webber,

It's not quite clear where you are storing the name of the picture file. Is it in the Mywholepict variable?

If so, you might need to wrap it in a call to LOADPICTURE():

objPicture = .InlineShapes.AddPicture(LOADPICTURE(mywholepict) , .F., .T.)

LOADPICTURE() returns an object reference to an image whose filename is passed as a parameter.

This is only a guess. I'm not an expert.

Mike



Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Code:
LOCAL cPicturePath, oWord, oDoc, oTextBox, oPicture, oTimer

* Image assumes you are running XP, 
* otherwise use appropriate image file
cPicturePath = "c:\windows\Rhododendron.bmp"

oWord = CREATEOBJECT("Word.Application")
oWord.VISIBLE = .T.
oDoc = oWord.documents.ADD()
oTextBox = oDoc.Shapes.AddTextbox(1,100,100,100,100)

WITH oTextBox
  oPicture = ;
    .TextFrame.TextRange.InlineShapes.AddPicture( ;
     cPicturePath , .F., .T. ;
     )
ENDWITH

oTimer = CREATEOBJECT("clsTimer", oWord)

READ EVENTS

DEFINE CLASS clsTimer AS TIMER
  ENABLED = .T.
  INTERVAL = 5000 && Fire in 5 seconds
  oWord = NULL

  PROCEDURE INIT(oWord)
    WITH THIS
      .oWord = oWord
    ENDWITH

  PROCEDURE TIMER
    WITH THIS
      .ENABLED = .F.
      .oWord.Documents(1).CLOSE(.F.)
      .oWord.QUIT()
    ENDWITH

    CLEAR EVENTS

  ENDPROC

ENDDEFINE

Darrell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top