Forum » Programiranje » Enostavni macro
Enostavni macro
amacar ::
Pozdrav!
Napisal sem enostaven macro, ki lepo deluje v wordu 2003, pri 2007 pa se pojavi težava.
V vrstici Open MyFile For Output As fnum je napaka, javi pa Run-time error 75: Path/File access error. Je mogoče kdo imel enak problem in mu ga je uspelo rešiti?
Koda:
Napisal sem enostaven macro, ki lepo deluje v wordu 2003, pri 2007 pa se pojavi težava.
V vrstici Open MyFile For Output As fnum je napaka, javi pa Run-time error 75: Path/File access error. Je mogoče kdo imel enak problem in mu ga je uspelo rešiti?
Koda:
Sub test()
Dim MyString As String
Dim MyString1 As String
Dim strName As Integer
Dim strName1 As Integer
strName = InputBox(Prompt:="Vnesi stran začetne tabele", _
Title:="Stran tabele")
strName1 = InputBox(Prompt:="Vnesi število tednov", _
Title:="Število tednov")
For k = 1 To strName1
For j = 2 To ActiveDocument.Tables(strName).Rows.Count
MyString = MyString + "<tr>"
For i = 1 To 5
Set OneCell = ActiveDocument.Tables(strName).Cell(j, i).Range
MyString1 = OneCell.Text
MyString1 = Mid(MyString1, 1, Len(MyString1) - 2)
If i > 1 Then
MyString1 = Replace(MyString1, Chr(13), "<br />")
Else
Dim temp As String
Dim temp1 As String
temp = Left(MyString1, 5)
temp1 = Mid(MyString1, 6, Len(MyString1) - 5)
temp1 = Replace(temp1, Chr(13), "<br />")
MyString1 = temp + temp1
End If
MyString = MyString + "<td>" + MyString1 + "</td>"
Next i
MyString = MyString + "</tr>"
Next j
strName = strName + 1
MyString = MyString + "<tr style=""height:15px""></tr>"
Next k
Dim pot As String
pot = Application.ActiveDocument.Path
MyFile = pot & "/jedilnik.txt"
fnum = FreeFile()
Open MyFile For Output As fnum
Print #fnum, MyString
Close #fnum
MsgBox ("konec")
End Sub
darkkk ::
Na prvi pogled bi moral bit \jedilnik.txt ne pa /jedilnik.txt (tole je odvisno od jezika, okolja ... ).
V msgbox vrži MyFile preden ga odpreš, pomoje je v tem stringu težava.
V msgbox vrži MyFile preden ga odpreš, pomoje je v tem stringu težava.
amacar ::
Hvala mojster, ko sem spremenil v \jedilnik.txt pa dela. Je pa čudno, da je v wordu 2003 tudi prejšnja zadeva delala.
Zgodovina sprememb…
- spremenil: amacar ()
Vredno ogleda ...
| Tema | Ogledi | Zadnje sporočilo | |
|---|---|---|---|
| Tema | Ogledi | Zadnje sporočilo | |
| » | C# INSERT statment ne vpise podatkovOddelek: Programiranje | 1329 (1203) | darkolord |
| » | Dll napisan v C++ importan v C# aplikacijoOddelek: Programiranje | 4313 (4100) | cikopero |
| » | [php]$_POST iz šumnikov v nešumnikeOddelek: Izdelava spletišč | 1783 (1695) | Gost |
| » | C#, Dodajanje podatkov v Arraylist z GumbomOddelek: Programiranje | 2410 (2249) | Beezgetz |
| » | VB in StringOddelek: Programiranje | 1019 (957) | mov ax 0x7c0 |