通过Microsoft Word中的书签从URL插入图像 [英] Insert image from URL via bookmark in Microsoft Word

查看:117
本文介绍了通过Microsoft Word中的书签从URL插入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧这可能不是一个编程问题,只是我怎么回答问题。



我的sql中包含一个图像URL数据库。我在word文档中为该列创建了一个书签。(这很好用)



现在我想使用从数据库传递的图像URL来插入图片。



我试过超链接(不工作但不显示图像)我试过快速部件 - 包括图片(不工作)。



过去一周我一直在谷歌我的屁股,但没有发现任何有用的东西。



任何帮助请? ?????????





好​​的,让我简化一下。我想使用URL插入图像。你可以用我认识的很多不同的方式做到这一点。



例如使用快速部件和选择IncludePicture你会过去插入图片的URL和BAM图像。



现在我想用一个例外做到这一点。 URL是我从数据库中获取的Microsoft Word书签。出于某种原因,这不想工作。我还检查了书签数据,这是正确的,是的,它是一个有效的URL,因为如果我按照上面描述的方式从数据库中复制并粘贴它就可以了。



那么有没有其他方法可以做到这一点?





我提供的word-vba代码看起来像这个。



  Sub  Insert_picture()

Dim Google 作为 字符串

< pre> Sub Insert_picture()

Dim Google As 字符串

Google = http://maps.googleapis.com/maps/api/staticmap?center=( -26.2041028,28.047305100000017)& zoom = 17& size = 500x500& markers = size:large%7Ccolor:red |(-26.2041028 ,28.0473051000 00017)& sensor = false& region = ZA

ActiveDocument.Bookmarks( MAPURL)。Range.InlineShapes.AddPicture Google, True True

结束 Sub





所以现在我的问题(使用此代码)。有没有办法将Google字符串设置为MAPURL书签?

我需要动态生成不同位置的图像。 (每个文件都有不同的位置)

希望这有助于使我想要的东西更清晰



再次任何帮助将非常感谢。

解决方案

检查此代码:



 < span class =code-keyword> Sub  Insert_picture()

Dim Google 作为 字符串

ActiveDocument.Bookmarks( MAPURL)。选择
Google = Selection.Text

ActiveDocument。书签( MAPURL)。Range.InlineShapes.AddPicture Google, True True

结束 Sub







请注意,占位符书签只包含网址,而不是别的。


我在这里查看书签数据库,如果它包含mapurl书签,则它将文档上的占位符书签设置为null,并将图像插入文档的底部(书签所在的位置)



 如果 MyBookMarks.Item(书签).Name =    mapurl 然后 

MyBookMarks.Item(书签) .Range.Text =

Dim oRange 作为 对象 = MyBookMarks.Item(书签).Range
Dim saveWithDocument As 对象 = True
Dim 缺少作为 对象 = Type.Missing

appWord.Application.Selection.InlineShapes.AddPicture(cmd.Columns.Item(书签).ToString(),missing,saveWithDocument,oRange)
否则


Ok this might not be as much a programming question as just a how the hell do I do it question.

I have a image URL contained in my sql database. I create a bookmark for that column in the word document.(this works fine)

Now I want to use the image URL that is passed from the database to insert an image.

I have tried hyperlink(DOES NOT WORK and DOES NOT DISPLAY IMAGE) I have tried Quick Parts - IncludePicture (DOES NOT WORK).

I have been Googleing my ass of for the past week and have not found anything that works.

ANY HELP PLEASE???????????


Ok let me simplify this. I want to insert a image using an URL. You can do this in alot of different ways I know.

For instance using Quick Parts and the selecting IncludePicture you would the past the URL of the picture and BAM image inserted.

Now I want to do exactly that with one exception. The URL is a microsoft word bookmark that I get from my database. For some reason this does not want to work. I have also checked the bookmark data and it is correct and yes it is a valid URL because if I copy and paste it from the database in the way I described above it works.

So is there any other way to do this?


I have been supplied with word-vba code that looks something like this.

Sub Insert_picture()

Dim Google As String

<pre>Sub Insert_picture()

Dim Google As String

Google = "http://maps.googleapis.com/maps/api/staticmap?center=(-26.2041028, 28.047305100000017)&zoom=17&size=500x500&markers=size:large%7Ccolor:red|(-26.2041028, 28.047305100000017)&sensor=false&region=ZA"

ActiveDocument.Bookmarks("MAPURL").Range.InlineShapes.AddPicture Google, True, True

End Sub



So now my question(using this code). Is there a way to set the Google string to the MAPURL bookmark?
I need to dynamically generate the image for different locations. (Different location for each document that is greated)
Hope this helps make what I am looking for a bit clearer

Again any help will be greatly appreciated.

解决方案

Check this code:

Sub Insert_picture()

Dim Google As String

ActiveDocument.Bookmarks("MAPURL").Select
Google = Selection.Text

ActiveDocument.Bookmarks("MAPURL").Range.InlineShapes.AddPicture Google, True, True

End Sub




Be aware to have the placeholder bookmark only covering the url, and nothing else.


Here I check for the bookmark in the database and if it contains the mapurl bookmark it then takes the placeholder bookmark on the document and sets its text to null and the inserts the image at the bottom of the document(where the bookmark is located)

If MyBookMarks.Item(bookmark).Name = "mapurl" Then

                    MyBookMarks.Item(bookmark).Range.Text = ""

                    Dim oRange As Object = MyBookMarks.Item(bookmark).Range
                    Dim saveWithDocument As Object = True
                    Dim missing As Object = Type.Missing

                    appWord.Application.Selection.InlineShapes.AddPicture(cmd.Columns.Item(bookmark).ToString(), missing, saveWithDocument, oRange)
                Else


这篇关于通过Microsoft Word中的书签从URL插入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆