Using VBA via ActiveX?

S

Sparky191

Are there any issues to be aware of in running VBA via ActiveX controls,
and creating docs from webpages etc.
 
M

Malcolm Smith

Yes

1. Don't use the ActiveDocument pointer. Instead grab hold of the
document pointer when you create or open a document and use that.

2. Don't use early binding. Use late binding.

These are the first two which spring to mind.

- Malc
 
P

Pete Bennett

3. Use an error trap to make sure that Excel (I assume that's what you're
automating) is actually installed before you start doing anything serious
(just a simple on error trap just after you perform the CreateObject should
do it).

4. Make sure there aren't any dialogs open in Excel that could mess up your
Automation.

This is the check I use in Word...

Private Function IsWordAvailable(oWord As Word.Application) As Boolean
Dim lngAddinCount As Long
On Error GoTo ErrHandler
IsWordAvailable = True

lngAddinCount = oWord.AddIns.Count
On Error GoTo 0
Exit Function
ErrHandler:
MsgBox "There appears to be a dialog box open in Word." & vbCr & vbCr & "You
should close down any open dialog screens before attempting to create a
document.", vbInformation, "Automation Error"
IsWordAvailable = False
 

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