Adding InlineShape makes Word freeze

F

Flemming

Hi,

I'm adding a picture like shown below.. into Word 2007

Just before adding I get some data from another word file..

When I break the code here and step trough the code with F8 it runs
perfectly , but when it runs without a break Word just freeze

Do anybody know why?

Thanks alot,
Flemming




Dim rBookmark As Range
Dim oIS As InlineShape
Set rBookmark = oDoc.Bookmarks(sBookmarkName).Range
Set oIS = rBookmark.InlineShapes.AddPicture(FileName:=sFullFileName,
LinkToFile:=False, SaveWithDocument:=True)

If Not oBorderLineStyle = wdLineStyleNone Then
With oIS
With .Borders(wdBorderTop)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderBottom)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderLeft)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderRight)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
End With
End If
End If
 
J

Jean-Guy Marcil

Flemming said:
Hi,

I'm adding a picture like shown below.. into Word 2007

Just before adding I get some data from another word file..

When I break the code here and step trough the code with F8 it runs
perfectly , but when it runs without a break Word just freeze

Do anybody know why?

In the line

If Not oBorderLineStyle = wdLineStyleNone Then

what is

oBorderLineStyle

???

How/when is it defined?
 
F

Flemming

Here goes the full function



Public Sub PictureToBookmark( _
ByVal oDoc As Document, _
ByVal sBookmarkName As String, _
ByVal sFullFileName As String, _
Optional oBorderLineStyle As WdLineStyle = wdLineStyleSingle, _
Optional dWidthCM As Double = 0)

'Indsætter et billede i en bogmærke
Dim rBookmark As Range
Dim oIS As InlineShape

If sFullFileName = gsNOT_SELECTED Then GoTo ProgErr_FileNotSelected
If Not modFileFunctions.SO_FileExists(sFullFileName) Then GoTo
ProgErr_FileNotValid

If oDoc.Bookmarks.Exists(sBookmarkName) Then
Set rBookmark = oDoc.Bookmarks(sBookmarkName).Range
ContentToBookmark oDoc, sBookmarkName, ""
Set oIS = rBookmark.InlineShapes.AddPicture(FileName:=sFullFileName,
_
LinkToFile:=False, SaveWithDocument:=True)
If Not dWidthCM = 0 Then oIS.Width = CentimetersToPoints(dWidthCM)
If Not oBorderLineStyle = wdLineStyleNone Then
With oIS
With .Borders(wdBorderTop)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderBottom)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderLeft)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderRight)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
End With
End If
End If

ProgErr_FileNotSelected:
ProgErr_FileNotValid:

Finito:
Set oIS = Nothing
Set rBookmark = Nothing
End Sub
 
F

Flemming

I have moved the insert picture up before I insert information from a dialog
into
ContentControls and add information from another file into ContentControls -
now it seems to
work...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top