Selection.InlineShapes.AddOLEObject ... causes (wellknown) error, any workaround

  • Thread starter Thomas Lindberg
  • Start date
T

Thomas Lindberg

I have a macro that out of an text file creates a Word doc by applying
context sensitive logic and selection.
The text file contains sometimes an URL to a server inside our company
domain, the URL points to a
specific file that shall be inserted into the Word doc.
The URL looks like this
\\servername.mycomp.com\folder1\subfolder\subsubfolder\aFile.pdf
alternative the IP-addr of the server.

If the file is an Office type file (.doc, .xls, .ppts, etc) the standard
Selection.InsertFile URL
works fine as expected.

If the URL points to a .pdf the method above produces garbage.

The alternative metod
Selection.InlineShapes.AddOLEObject ...
doesn't work, I get the error reported in
http://support.microsoft.com/default.aspx?scid=kb;en-us;819031
(The method works if I have the file locally in my PC)

Neither of the two proposed workaround methdods work, I get an run-time
error message saying
" ODBC Driver Manager: Data source too long "

I can not find any comfort and help that applies the Word VBA searching the
net for this.

Anybody here that has a solution/workaround for this??
(And possibly an explanation why this isn't solved, seems to be a wellknown
error.)

TIA

Thomas
 
J

Jay Freedman

Hi Thomas,

I don't know why Method 2 in the KB article recommends using ADODB to
copy the file to the local drive -- that seems like overkill, besides
the fact that it doesn't work for you. Instead, use any of the
ordinary methods of copying a file, such as the FileCopy statement or

Shell "cmd /c copy /b \\server\share\path\file.pdf c:\temp\file.pdf"

Once the file in on the local drive, embed it in the document and then
Kill the local copy as in the KB article.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
T

Thomas Lindberg

Thanks, Jay!

Works of course!

Thomas
Jay Freedman said:
Hi Thomas,

I don't know why Method 2 in the KB article recommends using ADODB to
copy the file to the local drive -- that seems like overkill, besides
the fact that it doesn't work for you. Instead, use any of the
ordinary methods of copying a file, such as the FileCopy statement or

Shell "cmd /c copy /b \\server\share\path\file.pdf c:\temp\file.pdf"

Once the file in on the local drive, embed it in the document and then
Kill the local copy as in the KB article.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may 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