PDA

View Full Version : Inserting Pictures



cleturno
05-12-2006, 09:22 AM
I have a doc that I am tyring to get the user to click on a image control box and then they have to insert it. It works, but it is requiring me to take the image off my comp it crashes on network image files and also must go back and froth between design mode to see the change. Any suggestions:

Private Sub LogoPic_Click()
Dim Doc As Dialog
Dim BClicked As String
Dim picPath As String
Dim picName As String
Dim oRg As Range
Const max_width As Long = 100
Const pic_path As String = "C:\TEMP"
Set Doc = Dialogs(wdDialogFileOpen)
With Doc
.Name = "*.jpg"
BClicked = .Display
picName = .Name 'picName holds the picture name
End With
picPath = CurDir & "\" & picName 'picPath holds the picture path
LogoPic.Picture = LoadPicture(picPath)
End Sub


Yes I did borrow this from somewhere else on the site and it works great except for that.

Thanks ahead of tiem

fumei
05-12-2006, 03:45 PM
And the Const pic_path As String = "C:\TEMP" is used for??

TonyJollans
05-13-2006, 02:25 AM
I'm a bit confused by this.

Leaving everything else aside, you display a dialog for the user to choose a picture and then ignore the chosen path and use CurDir instead.

fumei
05-13-2006, 09:36 PM
That too.

cleturno
05-15-2006, 06:30 AM
So If I take the 'picPath holds the picture path[/COLOR]
]

and move it up inside the With doc that might help

TonyJollans
05-15-2006, 06:34 AM
No.

It is the use of CurDir that I question, not the location of the line.

cleturno
05-15-2006, 06:56 AM
suggestions?

TonyJollans
05-15-2006, 07:44 AM
Try using Application.FileDialog (assuming you have a recent version of Word) as t hat will give you the path as well.

cleturno
05-15-2006, 08:46 AM
Ok, I think this is how I usse it, but correct me if I am wrong

Private Sub CommandButton1_Click()
Dim Doc As FileDialog
Dim BClicked As String
Dim picPath As String
Dim picName As String
Dim oRg As Range
Const max_width As Long = 100
Const pic_path As String = "C:\TEMP"
Set Doc = Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
With Doc
.Show
.AllowMultiSelect = False
picPath = vrtSelectedItem
LogoPic.Picture = LoadPicture(picPath)
End With

End Sub


I can't find the lib structre or how this works any where in the help I am searching in the MSDN libs now to understand the object better.

TonyJollans
05-15-2006, 09:12 AM
Real quick as I'm off out now but you want something like ..

Set Doc = Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
With Doc
.AllowMultiSelect = False
.Show
picPath = .SelectedItems(1)
end with
LogoPic.Picture = LoadPicture(picPath)

cleturno
05-15-2006, 09:22 AM
That takes care of the netowrk issue, but why does the image not update until I go into design mode again?

cleturno
05-15-2006, 01:27 PM
Private Sub CommandButton1_Click()
On Error Resume Next
Dim Doc As FileDialog
Dim BClicked As String
Dim picPath As String
Dim picName As String
Dim oRg As Range
Application.ScreenUpdating = True
Application.ScreenRefresh = True
Set Doc = Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
With Doc
.AllowMultiSelect = False
.Show
picPath = .SelectedItems(1)
End With
LogoPic.Picture = LoadPicture(picPath)
End Sub



This is working great except for the fact that the image never shows up in LogoPic. You have to go into design mode or access the header which it is contained in. Any thoughts?

TonyJollans
05-16-2006, 07:03 AM
Sorry but I don't know.

I have had a play with this and can see the problem but at the moment do not know the solution.

fumei
05-16-2006, 12:49 PM
access the header which it is contained inAre you saying this is an ActiveX control in a header?

cleturno
05-18-2006, 06:29 AM
IT is a standard form picture box in the header. Do I need to be using an active x controller?

fumei
05-18-2006, 10:56 PM
What do you mean by "standard form picture box"?

Could you please tell me exactly the steps to get this box in the header? In other words....what the heck IS LogoPic? If it is using .Picture then that sounds like an ActiveX control. You get those using the Controls toolbar. Is that what you did?

fumei
05-18-2006, 10:58 PM
In fact, it has to be. I know of nothing else that takes a .LoadPicture method.

I would hardly call it a "standard form picture box". The next question is WHAT activex control. A textbox will take an image; a checkbox will take an image; an imagebox will take an image.

It is one of the oddities of ActiveX controls that if you want to be RE-loading images, an Imagebox is not the best control to use.