Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
HELP!!! using full hyperlink filepath within VBA/API
Hello all,
I'm having a slight problem, I have developed with the help of many a googlesearch and message board a script that extras the hyperlinks and prints the linked documents to various printer dependant on rules. My Problem is this.... ../../sillypath/document.dwf How can I make it so that the ../ paths are replaced by the correct full path of the linked document given that some documents are local some are on the network and some could even be on the internet. help.... :P URL = hlnk.address is the command that gets me the hyperlink Many Many thanks for any help! Dave |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
HELP!!! using full hyperlink filepath within VBA/API
Can you paste your code i'm not sure what you're after.
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
HELP!!! using full hyperlink filepath within VBA/API
On 23 Oct, 10:11, anon wrote:
Can you paste your code i'm not sure what you're after. My code is below, basically it extracts a range of hyperlinks (that were put into the document using =hyperlink() function) but hyperlinks in a similar folder structure are shortened from the full file path to ../folder/file.ext with the print function using shellexecute and therefore operating windows itself it needs to use the full filepath c:\whatever\folder \file.ext I could make a work around if these were in standard file paths, however, the file locations are spread out across the network and therefore i can't see this as being possible. So I need some code that basically takes the hyperlink and converts it to the full filepath Many Thanks David ----------------------- Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Option Explicit Option Compare Text Dim PrintURL As String Dim URL As String Dim hlnk As Hyperlink Dim Printer As String Dim PaperSizeA4 As String Dim PaperSizeA3 As String Dim PaperSizeA2 As String Dim PaperSizeA1 As String Dim PaperSizeA0 As String Dim OldPrinter As String Dim msg As String Dim SelRange As Range Dim Addr As String Dim sMyDefPrinter As String Dim myRegKey As String Dim myValue As String Dim myAnswer As Integer Dim strProgram As String Private Sub UserForm_Initialize() PaperSizeA4 = "\\yorkshire2\KONICA MINOLTA C350 PCL5c" PaperSizeA3 = "\\yorkshire2\KONICA MINOLTA C350 PCL5c A3" PaperSizeA2 = "\\yorkshire2\OCE TDS300 A2" PaperSizeA1 = "\\yorkshire2\OCE TDS300 A1" PaperSizeA0 = "\\yorkshire2\OCE TDS300" End Sub ' ############################ START OF PRINTING SCRIPTS ################## ############### Private Sub OKButton_Click() Dim Papersizes As String Dim cell As Range Addr = RefEdit1.Value myRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT \CurrentVersion\Windows\Device" sMyDefPrinter = RegKeyRead(myRegKey) ' ##### OPENS ADOBE READER 8.0 'strProgram = "C:\Program Files\Adobe\Reader 8.0\Reader\Acrord32.exe" 'Call ShellExecute(vbNull, vbNull, strProgram, vbNull, vbNull, vbNull) ' ##### DWF Viewer 'strProgram = "C:\Program Files\Autodesk\Autodesk DWF Viewer \DWFViewer.exe" 'Call ShellExecute(vbNull, vbNull, strProgram, vbNull, vbNull, vbNull) For Each hlnk In Range(Addr).Hyperlinks If hlnk.Range.Offset(0, 1).Text = "A4" Then URL = hlnk.Address Printer = GetPrinterKey(PaperSizeA4) RegKeySave myRegKey, Printer Call ShellExecute(0&, "print", URL, vbNullString, vbNullString, vbNormalFocus) End If ' Next ' Sleep (10000) 'For Each hlnk In Range(Addr).Hyperlinks If hlnk.Range.Offset(0, 1).Text = "A3" Then URL = hlnk.Address Printer = GetPrinterKey(PaperSizeA3) RegKeySave myRegKey, Printer Call ShellExecute(0&, "print", URL, vbNullString, vbNullString, vbNormalFocus) End If 'Next ' Sleep (10000) 'For Each hlnk In Range(Addr).Hyperlinks If hlnk.Range.Offset(0, 1).Text = "A2" Then URL = hlnk.Address Printer = GetPrinterKey(PaperSizeA2) RegKeySave myRegKey, Printer Call ShellExecute(0&, "print", URL, vbNullString, vbNullString, vbNormalFocus) End If ' Next ' Sleep (10000) 'For Each hlnk In Range(Addr).Hyperlinks If hlnk.Range.Offset(0, 1).Text = "A1" Then URL = hlnk.Address Printer = GetPrinterKey(PaperSizeA1) RegKeySave myRegKey, Printer Call ShellExecute(0&, "print", URL, vbNullString, vbNullString, vbNormalFocus) End If ' Next ' Sleep (12000) ' For Each hlnk In Range(Addr).Hyperlinks If hlnk.Range.Offset(0, 1).Text = "A0" Then URL = hlnk.Address Printer = GetPrinterKey(PaperSizeA0) RegKeySave myRegKey, Printer Call ShellExecute(0&, "print", URL, vbNullString, vbNullString, vbNormalFocus) End If Sleep (5000) Next RegKeySave myRegKey, sMyDefPrinter Unload UserForm1 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hyperlink does not show full address | Excel Discussion (Misc queries) | |||
How to I display the full path of an hyperlink in MS Excel 2000? | Excel Discussion (Misc queries) | |||
How to convert a hyperlink to its target full-text URL | Excel Discussion (Misc queries) | |||
Printing Word Document from Hyperlink -- Can't get the full path!!! Please Help | Excel Programming | |||
Function to return filepath given full filename | Excel Programming |