Macro to open hyperlink

  • Thread starter Thread starter Craig Lawson
  • Start date Start date
C

Craig Lawson

Hello. I have a spreadsheet that has a list of numbers
representing debit memos. I can use these numbers to
either create a link or open directly a copy of the debit
on the debiting company's server. I would like to create
a macro that will open the document, and print the
document. This macro will loop down the list to print out
the whole list. This is what I have tried so far:

1. I created links in the spreadsheet to the various
files. Following one of these links opens it in a web
browser. I am unable / don't know how to print the
webpage from within the macro. This is the fastest of the
methods to open the document

2. I opened the link directly from the macro. This
opened the document in a separate excel workbook each
time. The document opens larger than 1 page. Due to time
opening the document, the macro blows through any page
formatting before the document is open and prints on 2
pages.

I would prefer to be able to open these in the web browser
and print from there if possible. This is both faster,
and only opens 1 extra window.

All suggestions are appreciated

Craig
 
Craig

If you automate Internet Explorer, you may be able to print the browser
window from within Excel. You'll need to set a reference to Microsoft
Internet Controls. Here's an example:

Sub printweb()

Dim ie As InternetExplorer

Set ie = New InternetExplorer

ie.Visible = True

ie.Navigate Range("A1").Value 'A1 holds the URL

Do
DoEvents
Loop Until ie.ReadyState = READYSTATE_COMPLETE

'This prints it
ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

End Sub
 
Thanks Dick, I'll give this a try.
-----Original Message-----
Craig

If you automate Internet Explorer, you may be able to print the browser
window from within Excel. You'll need to set a reference to Microsoft
Internet Controls. Here's an example:

Sub printweb()

Dim ie As InternetExplorer

Set ie = New InternetExplorer

ie.Visible = True

ie.Navigate Range("A1").Value 'A1 holds the URL

Do
DoEvents
Loop Until ie.ReadyState = READYSTATE_COMPLETE

'This prints it
ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.




.
 

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

Back
Top