Direct print from link

Ivaylo1914

New Member
Joined
Feb 22, 2023
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hello :)

I need your help.
I am working on an Excel file of mine to organize my humble business.

I have a file in which in column "A" I dynamically receive links to PDF documents that are generated by my site.

Currently, our work process is as follows:
We enter ExceL, click on one of the hiperlink
- The link opens in mozilla, there is a PDF in it
- Press print (print the document)
- We close the file and move on.

The idea is to improve this action and when we click on the link, VBA issues a direct print command in the background.
I tried a lot of codes, but mostly I end up downloading the file, which is not my idea.
Could someone help me please :)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I tried this code but it didn't work either...

Sub PrintWebPage()
Dim ie As Object
Dim url As String
Dim cell As Range
Dim oShell As Object
Dim oWin As Object
Dim oDoc As Object
Get the URL from the selected cell
Set cell = Application.InputBox("Select the cell containing the URL:", Type:=8)
' Check if a cell was selected
If cell Is Nothing Then
MsgBox "No cell was selected."
Exit Sub
End If
' Get the URL from the cell
url = cell.Value
' Open the internet page in Mozilla Firefox
Set oShell = CreateObject("WScript.Shell")
Set oWin = CreateObject("Shell.Application")
oShell.Run """C:\Program Files\Mozilla Firefox\firefox.exe"" " & url
Do While oWin.Windows.Count < 2
DoEvents
Loop
For Each oDoc In oWin.Windows
If oDoc.Name Like "Mozilla Firefox*" Then
oDoc.Visible = True
Exit For
End If
Next
' Print the page
oShell.SendKeys "^p", True
' Close Mozilla Firefox
oDoc.Quit
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top