I've used the modified function from Albert Kalall for late-binding an
Access query to a merge Word doc. But I want to insert a picture, and I
cannot get this to work - no picture.
I have tried hitting the side of the monitor, but no help. Anyone?
Public Function MergeQuery(queryName As String, _
docName As String) As Boolean
On Error GoTo handle_error
MergeQuery = False
Dim i As Integer
Dim mWord As Object
Dim mDoc As Object
Set mWord = CreateObject("Word.Application")
DoCmd.TransferText acExportDelim, , queryName, _
"c:\odis\merge.txt", True
With mWord
Set mDoc = .Documents.Open(docName)
.ActiveDocument.MailMerge.MainDocumentType = 0
If .ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
.ActiveDocument.Unprotect
End If
.ActiveDocument.MailMerge.OpenDataSource Name:="c:\odis\merge.txt", _
AddToRecentFiles:=False, Format:=0, _
Connection:="", SQLStatement:="", SQLStatement1:=""
.ActiveDocument.MailMerge.Execute
.Application.Selection.Find.ClearFormatting
Do While .Application.Selection.Find.Execute(FindText:="<ff >", _
Wrap:=wdFindContinue, Forward:=True) = True
.ActiveDocument.FormFields.Add
Range:=.Application.Selection.Range, _
Type:=wdFieldFormTextInput
Loop
' --- Can't get the following to work
mWord.inlineShapes.AddPicture ("C:\odis\cache\0001622A.jpg", True,
Flase)
' --- This part right above here won't work
If .ActiveDocument.ProtectionType = wdNoProtection Then
.ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True, Password:=""
End If
.Application.Visible = True
mDoc.Close
End With
MergeQuery = True
exit_point:
Set mWord = Nothing
Set mDoc = Nothing
Exit Function
handle_error:
LogError "basAlbertDKalall.MergeQuery", Err.Description
GoTo exit_point
End Function
---------------------------------------
--
Darryl Kerkeslager 2 4799
Maybe:
mWord.ActiveDocument.Selection.inlineShapes.AddPic ture ("C:\odis\cache\0001622A.jpg", True, False)
Hth
Arno R
"Darryl Kerkeslager" <ke*********@comcast.net> schreef in bericht news:xo********************@comcast.com... I've used the modified function from Albert Kalall for late-binding an Access query to a merge Word doc. But I want to insert a picture, and I cannot get this to work - no picture. I have tried hitting the side of the monitor, but no help. Anyone? Public Function MergeQuery(queryName As String, _ docName As String) As Boolean On Error GoTo handle_error MergeQuery = False Dim i As Integer Dim mWord As Object Dim mDoc As Object Set mWord = CreateObject("Word.Application") DoCmd.TransferText acExportDelim, , queryName, _ "c:\odis\merge.txt", True With mWord Set mDoc = .Documents.Open(docName) .ActiveDocument.MailMerge.MainDocumentType = 0 If .ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then .ActiveDocument.Unprotect End If .ActiveDocument.MailMerge.OpenDataSource Name:="c:\odis\merge.txt", _ AddToRecentFiles:=False, Format:=0, _ Connection:="", SQLStatement:="", SQLStatement1:="" .ActiveDocument.MailMerge.Execute .Application.Selection.Find.ClearFormatting Do While ..Application.Selection.Find.Execute(FindText:="<f f>", _ Wrap:=wdFindContinue, Forward:=True) = True .ActiveDocument.FormFields.Add Range:=.Application.Selection.Range, _ Type:=wdFieldFormTextInput Loop ' --- Can't get the following to work mWord.inlineShapes.AddPicture ("C:\odis\cache\0001622A.jpg", True, Flase) ' --- This part right above here won't work If .ActiveDocument.ProtectionType = wdNoProtection Then .ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="" End If .Application.Visible = True mDoc.Close End With MergeQuery = True exit_point: Set mWord = Nothing Set mDoc = Nothing Exit Function handle_error: LogError "basAlbertDKalall.MergeQuery", Err.Description GoTo exit_point End Function --------------------------------------- -- Darryl Kerkeslager
Sorry, just tested and 'InlineShapes' did NOT work...
I have something like:
Function MergeWordDoc(strWordDoc As String)
......
Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(strWordDoc)
WordDoc.Shapes.AddPicture .... works
WordApp.ActiveDocument.Shapes.AddPicture ... works also
.....
Adapt to your needs
Also I think that you need to insert the picture *before* you perform the merge ?
Arno R This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris |
last post by:
Hi,
I am trying to set the position of a picture inside a picturebox with the
folowing code:
pctOutput.Picture = LoadPicture(App.Path & "\picture.bmp", ,
, , )
I didn't know what to fill...
|
by: Chris Coho, Jr. |
last post by:
Ok, I'll explain the whole problem because there may be several ways to
solve this and hopefully someone knows one. What I'm doing is creating
a specialty template editor, similar to say a corel...
|
by: Sandra Setz |
last post by:
Hi,
I was wondering if someone could explain to me what the difference is
between the width propery of the picture property of an image and the width
property of the image itself.
I would...
|
by: Sandra Setz |
last post by:
Hi,
Is it possible to assign the Picture property of a picturebox to the
Picture property of an image control?
I use an invisble picturebox to make some changes to a picture, but I
want to...
|
by: Lyn |
last post by:
I am trying to embed a picture into a Bound Object Frame (Me!Photograph)
with the following code which is based on MS article
http://support.microsoft.com/?id=158941:
strPathname =...
|
by: John Ortt |
last post by:
Hi there everyone,
I have a part info form which has a faded image of our company logo as a
background.
I want to replace the faded image with a bright red warning image on items
which have run...
|
by: NASAdude |
last post by:
I'm working on distributing a database using VS Tools for Office, and
am having trouble with linked images on forms/reports. The image
objects have a default path\file set on the .Picture property,...
|
by: Jeff |
last post by:
Hey
(and thank you for reading my post)
In visual web developer 2005 express edition I've created a simple website
project..
At this website I want users who register to be able to upload a...
|
by: raghunadhs |
last post by:
hi all!
i have a picture box, in that picture box, there is a picture asume it as "pic1.bmp".. now i have made some changes in that picture.
Now i want to load a picture to a image( my form...
|
by: orson4music |
last post by:
I have two picture boxes on my form. One on top of the other. The top most picture box's movement is restricted within the picture box below making it look like the top most picture box is contained...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |