Saving Activated OLE Object to a file?

G

Gary

I need help in saving an Excel (or Visio) program which is embed as an OLE
Object on a table.
In Access, I have activated the OLE object (from the table) and I am able to
edit the excel program in access.

How do I make an external file of the embeded OLE Object? If the embed
object was excel, I want to make an excel file. If I decide to use Viso,
then I want a visio file.


Thank You,

Gary
 
H

Henry

Take the 'DAO.Field' datatype and use the 'Put' function to output it.

that works fine with me

henry
 
S

Stephen Lebans

Henry how can you make the statement "that works fine with me"? Did you
actually test your suggested method? Perhaps you should test your solutions
before you post.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
H

Henry

Yes, I have done an implementation that reads and writes bitmap files to/from
OLE-objects.

Why are you so negative ?

henry
 
S

Stephen Lebans

Henery I was trying to to tell you that the solution you offered will not
work. If you take my correction negatively then that is your problem not
mine.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
S

Stephen Lebans

Once the object is Activated you would call the objects Save or SaveAs
method.

From the main Acccess Database window:

Press Ctrl + G to get to the VB IDE
RIght Click anywhere and select Object Browser
In the top left corner select the Library Combo, select the library of
interest - ie. Word or Excel
Examine the methods and properties the object exposes.

Above assumes you have set a Reference to the proper version of the MS
Office library.

Is this an ongoing issue where you want to save a copy of the object to
disk? Why not link instead of embedding? What exactly do you need to
accomplish?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Gary

Stephen:

This is a on go thing. What I really wanted was to create a file and then
the AddOLEObject to insert the OLE object into powerpoint.

The code below works, but it is displaying all of the windows and is slow.
I created a form with a bound object called OLEFile. I have a button which
execute the following code:

Dim oPPT As PowerPoint.Application
Dim oPres As Presentation
Dim xWidth As Integer, yHeight As Integer

Dim AppVisio As Visio.Application
Dim docsObj As Visio.Documents
Dim DocObj As Visio.Document
Dim pagsObj As Visio.Pages
Dim pagObj As Visio.Page
Dim db As Database
Dim T As DAO.Recordset

Set db = DBEngine.Workspaces(0).Databases(0)
Set T = db.OpenRecordset("tblLoadOLE")

T.MoveFirst

Set oPPT = New PowerPoint.Application
Set oPres = oPPT.Presentations.Add(True)

Const ppLayoutBlank = 12
Const ppSaveAsPresentation = 1

xWidth = (11 * 1440) / 20
'yHeight = (8.5 * 1440) / 20
yHeight = (6.8169 * 1440) / 20

oPres.PageSetup.SlideWidth = xWidth
oPres.PageSetup.SlideHeight = yHeight

Do Until T.EOF
'For i = 1 To 2

Me![OLEFile].Action = acOLEActivate

Set AppVisio = GetObject(, "visio.application")
Set DocObj = AppVisio.ActiveDocument
DocObj.SaveAs "c:\access 2006\MyDrawing.vsd"

AppVisio.Quit
Set AppVisio = Nothing

oPres.Slides.Add(oPres.Slides.Count + 1,
ppLayoutBlank).Shapes.AddOLEObject Left:=0, Top:=0, Width:=xWidth,
Height:=yHeight, FileName:="c:\access 2006\MyDrawing.vsd"
DoCmd.RunCommand acCmdRecordsGoToNext
T.MoveNext
Loop
' Next i

oPres.SaveAs "c:\access 2006\MyDrawing.ppt", ppSaveAsPresentation, True

oPres.Close
Set oPres = Nothing
oPPT.Quit
Set oPPT = Nothing


The code first of all activate the OLEObject from the Table and open it
separately. I set the verb = -2 on the bound object so I can saveAs to a
file. I then used the AddOLEObject with power point and inserted the object
into a side.

I assume I can link the object too??? How is this done??

Can someone help me improve upon my code??

Thank You,

Gary
 
S

Stephen Lebans

I have no experience in this area Gary. You probably should ask in a VISIO
NG to get the best answer.

OLe objects can be embedded or linked. If you kept the file external you
should be able to Link to it from an OLE control in both Access and
Visio.But I really do not understand everything you are trying to do here.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Gary said:
Stephen:

This is a on go thing. What I really wanted was to create a file and then
the AddOLEObject to insert the OLE object into powerpoint.

The code below works, but it is displaying all of the windows and is slow.
I created a form with a bound object called OLEFile. I have a button
which
execute the following code:

Dim oPPT As PowerPoint.Application
Dim oPres As Presentation
Dim xWidth As Integer, yHeight As Integer

Dim AppVisio As Visio.Application
Dim docsObj As Visio.Documents
Dim DocObj As Visio.Document
Dim pagsObj As Visio.Pages
Dim pagObj As Visio.Page
Dim db As Database
Dim T As DAO.Recordset

Set db = DBEngine.Workspaces(0).Databases(0)
Set T = db.OpenRecordset("tblLoadOLE")

T.MoveFirst

Set oPPT = New PowerPoint.Application
Set oPres = oPPT.Presentations.Add(True)

Const ppLayoutBlank = 12
Const ppSaveAsPresentation = 1

xWidth = (11 * 1440) / 20
'yHeight = (8.5 * 1440) / 20
yHeight = (6.8169 * 1440) / 20

oPres.PageSetup.SlideWidth = xWidth
oPres.PageSetup.SlideHeight = yHeight

Do Until T.EOF
'For i = 1 To 2

Me![OLEFile].Action = acOLEActivate

Set AppVisio = GetObject(, "visio.application")
Set DocObj = AppVisio.ActiveDocument
DocObj.SaveAs "c:\access 2006\MyDrawing.vsd"

AppVisio.Quit
Set AppVisio = Nothing

oPres.Slides.Add(oPres.Slides.Count + 1,
ppLayoutBlank).Shapes.AddOLEObject Left:=0, Top:=0, Width:=xWidth,
Height:=yHeight, FileName:="c:\access 2006\MyDrawing.vsd"
DoCmd.RunCommand acCmdRecordsGoToNext
T.MoveNext
Loop
' Next i

oPres.SaveAs "c:\access 2006\MyDrawing.ppt", ppSaveAsPresentation, True

oPres.Close
Set oPres = Nothing
oPPT.Quit
Set oPPT = Nothing


The code first of all activate the OLEObject from the Table and open it
separately. I set the verb = -2 on the bound object so I can saveAs to a
file. I then used the AddOLEObject with power point and inserted the
object
into a side.

I assume I can link the object too??? How is this done??

Can someone help me improve upon my code??

Thank You,

Gary

Stephen Lebans said:
Once the object is Activated you would call the objects Save or SaveAs
method.

From the main Acccess Database window:

Press Ctrl + G to get to the VB IDE
RIght Click anywhere and select Object Browser
In the top left corner select the Library Combo, select the library of
interest - ie. Word or Excel
Examine the methods and properties the object exposes.

Above assumes you have set a Reference to the proper version of the MS
Office library.

Is this an ongoing issue where you want to save a copy of the object to
disk? Why not link instead of embedding? What exactly do you need to
accomplish?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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