Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default HELP!!! using full hyperlink filepath within VBA/API

Can you paste your code i'm not sure what you're after.

  #3   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 13
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink does not show full address Jennifer Excel Discussion (Misc queries) 1 February 8th 10 06:44 PM
How to I display the full path of an hyperlink in MS Excel 2000? Hyperlinks Excel Discussion (Misc queries) 0 May 10th 07 03:55 PM
How to convert a hyperlink to its target full-text URL Excel Discussion (Misc queries) 2 July 7th 05 01:40 PM
Printing Word Document from Hyperlink -- Can't get the full path!!! Please Help JadPlane Excel Programming 0 April 17th 05 11:45 AM
Function to return filepath given full filename Matt Lawson[_3_] Excel Programming 8 March 3rd 04 02:32 AM


All times are GMT +1. The time now is 12:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"