home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 January
/
PCWorld_2005-01_cd.bin
/
software
/
vyzkuste
/
office
/
office.exe
/
pcwAddHyperlink.BAS
< prev
next >
Wrap
BASIC Source File
|
2004-11-09
|
4KB
|
125 lines
Const OFN_ALLOWMULTISELECT As Long = &H200
Const OFN_CREATEPROMPT As Long = &H2000
Const OFN_EXPLORER As Long = &H80000
Const OFN_EXTENSIONDIFFERENT As Long = &H400
Const OFN_FILEMUSTEXIST As Long = &H1000
Const OFN_HIDEREADONLY As Long = &H4
Const OFN_LONGNAMES As Long = &H200000
Const OFN_NOCHANGEDIR As Long = &H8
Const OFN_NODEREFERENCELINKS As Long = &H100000
Const OFN_OVERWRITEPROMPT As Long = &H2
Const OFN_PATHMUSTEXIST As Long = &H800
Const OFN_READONLY As Long = &H1
Const MAX_PATH As Long = 260
Const MAX_BUFFER As Long = 50 * MAX_PATH
Const sBackSlash As String = "\"
Const sPipe As String = "|"
Private Declare Function GetOpenFileName Lib "COMDLG32.DLL" Alias "GetOpenFileNameA" _
(pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "COMDLG32.DLL" Alias "GetSaveFileNameA" _
(pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetTempFileName _
Lib "kernel32" Alias "GetTempFileNameA" _
(ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Declare Function DeleteFile Lib "kernel32" Alias _
"DeleteFileA" (ByVal lpFilename As String) As Long
Private Declare Function MoveFile Lib "kernel32" Alias _
"MoveFileA" (ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String) As Long
Private Declare Function GetFullPathName Lib "kernel32.dll" Alias _
"GetFullPathNameA" (ByVal lpFilename As String, ByVal nBufferLength As Long, _
ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String ' Can also be a Long.
End Type
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Sub pcwAddHyperlink()
Dim OFN As OPENFILENAME
OFN.Flags = OFN.Flags Or OFN_EXPLORER Or OFN_LONGNAMES Or OFN_HIDEREADONL
With OFN
.lStructSize = Len(OFN)
.nMaxFile = IIf(.Flags And OFN_ALLOWMULTISELECT, MAX_BUFFER + 1, MAX_PATH + 1)
.nMaxFileTitle = MAX_PATH + 1
.lpstrFile = .lpstrFile & String$(.nMaxFile - 1 - Len(.lpstrFile), 0)
.lpstrFilter = "VÜechny soubory (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"Texty, Tabulky" & Chr(0) & "*.doc;*.rtf;*.txt;*.htm;*.html;*.xls;*.ppt;*.url" & Chr(0) & _
"Obrßzky, Hudba" & Chr(0) & "*.jpg;*.jpeg;*.bmp;*.tif;*.tiff;*.pcx;*.gif;*.wav;*.mp3;*.wma;*.ogg" & Chr(0) & _
"Archφvy, Programy" & Chr(0) & "*.zip;*.rar;*.exe;*.dll;*.bat;*.hta;*.vbs;*.js;*.ocx" & Chr(0)
ret = GetOpenFileName(OFN)
If ret <> 0 Then
datei = .lpstrFile
Else
Exit Sub
End If
End With
Do
t = t + 1
temp = Mid(datei, t)
Loop While InStr(temp, "\")
dateiname = Mid(datei, t)
wordfilepfad = ActiveDocument.Path
wordfilename = ActiveDocument.Name
If wordfilepfad = "" Then
MsgBox "P°ed vlo₧enφm odkazu nejprve dokument ulo₧te!"
Exit Sub
End If
temp = InStr(wordfilename, ".")
ohneExtension = Left(wordfilename, temp - 1)
ziel = wordfilepfad & "\" & ohneExtension & "_" & dateiname
If UCase(datei) <> UCase(ziel) Then
FileCopy datei, ziel
End If
Selection.TypeParagraph
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
ohneExtension & "_" & dateiname, SubAddress:=""
Selection.TypeParagraph
End Sub