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!

Get Picture and Selecting it

Status
Not open for further replies.

bizybeaver

Technical User
Apr 7, 2004
26
US
I had some trouble with this, but I finally got it to work. Problem I have now is I need to allow the user get select a file, via Insert Picture from File as opposed to me hard coding the path. I'm not sure how to get this in and then perform the formatting steps I need afterwards...

Any help is greatly appreciated!

Set myShape = ActiveDocument.Shapes.AddPicture(FileName:="G:\PDG Stock Binders~New Sprint Nextel\Vertical Market Covers\Business~Professional Services\Business Voice & Data Letter Sized.jpg", LinkToFile:=False, SaveWithDocument:=True, Anchor:=Selection.Range)
'Dialogs(wdDialogInsertPicture).Show
myShape.Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0#

etc... More steps are listed, but redundant for this post.
 


Hi,

Take a look at the getOpenFileName method

Skip,
[sub]
[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue][/sub]
 
I did try SetmyShape = Dialogs(wdDialogInsertPicture).Show

But I get an error. I also did try the GetOpenFileName before, but for some reason, I could not figure out what the Shape was called (named). Then I couldn't modify it. THis is the farthest I've come and the code works perfectly, but I just need the user to pic their file first.
 

...but for some reason, I could not figure out what the Shape was called (named).
Shape? Where did that come from? This is picking a filename, is it not?


Skip,
[sub]
[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue][/sub]
 
From what I understand, when inserting a file (or object) it comes in as InLineShape. I need it converted to Shape so I can modify it appropriately to be behind text, etc. If you look at the latter part of my code you will see I use the ShapeRange to control the Shape (or picture).

So does the getOpenFileName open a dialog box to "fetch" a picture? I was experimenting with InsertPicture but again, I lost "focus". Thanks for your help!
 
Seem to be at cross purposes here...

Skip, you are asking about a filename. Yes, that would be good. Then the filename could be used - as a string - to put in the code, as in:
Code:
Set myShape = ActiveDocument.Shapes.AddPicture(FileName:=[i]filename_string[/i] etc. etc.

On the other hand, bizybeaver seems to want the insertpicture dialog itself displayed.  In which case the result will go into the document.  

So I am confused.  Do you want a filename to use in your code, or do you want the user to select the image file with the dialog?

Gerry
 
Hi, thanks for the help.

I was testing whether I could format the picture, which I now have successfully done. However, when I was testing, I hard-coded the filename.

Now, I need to change and put up a dialog for the user to select their image, then run the code to format as necessary (i.e., change fron InlineShape to Shape and reset size, send to back, etc...

What I can't figure out is how to allow the user to insert a pic then run the subsequent code on that object. I've found other posts, but for some reason, I'm having difficulty finding the name of the object once it's inserted.

I was wondering if I could make a macro (or link) that when the user clicked on it, it would open the insert picture from file dialog box then run the rest of my code.

I hope that makes sense!

Thanks again for your help and direction!
 
Use the index of InlineShapes. Once the user inserts an image (with your dialog), then the LAST index count should be that image. Declare and set an object variable for it.

This is a very convoluted part of the Word object model. It is NOT intuitive, and it is NOT covered very well in Help. Also there are some properties that are NOT included in Intellisense.

They got a bit shloppy here....

Gerry
 
Ok, I'm a newbie to this, but I see where you're going.

I need to start my code with the dialog box, then make something like this? I'm struggling with the right syntax.

ActiveDocument.InLineShape.Count
'Somehow select the last Shape
'Convert it to a Shape
'proceed with rest of my code.

Can anyone help me out with the first part of this?
Thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top