-1

1つの列に救済チケット番号(HD0000001006530など)があります。

自分自身を参照する各セルにハイパーリンクを作成する必要があります。ハイパーリンクをクリックすると、マクロが実行されます。

マクロは、以下のような内容の.artaskタイプのファイルを作成し、それを開く必要があります。.artaskファイルを開くと、救済策としてチケットHD0000001006530が開きます。


[ショートカット]
名前=HPD:ヘルプデスク
タイプ=0
サーバー=remedyprd
チケット= HD0000001006530 <---この値はExcelセルから取得されます

4

1 に答える 1

1

マクロ対応のExcelファイルで、このコードを選択した「ワークシート」コードペインにコピーします。

           Private Function Createfile(ByVal cellvalue As String)
            Open "c:\" & cellvalue & ".artask" For Output As #1 'your target file name and address. you may change it to the desired folder
            Print #1, "[Shortcut]"
            Print #1, "Name = HPD: HelpDesk"
            Print #1, "Type = 0"
            Print #1, "Server = remedyprd"
            Print #1, "Ticket =" & cellvalue
            Close #1
           End Function

 'EDIT BEGINS:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Dim cell As Range
 If Dir("C:\" & cellvalue & ".artask") = "" Then 'For memory optimization we should first check if the file exists or not

For Each cell In Range("A1:A" & Me.UsedRange.Rows.Count) 'Specify the Range, in that case it is from A1 to end of the column A
   cell.Select
  ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="c:\" & Selection.Text & ".artask", TextToDisplay:=Selection.Text

    Next cell 'Loop through cells

            Createfile (Selection.Value)
        End If
          End If

      End Sub
    'EDIT ENDS

何か問題があれば教えてください。

于 2013-02-12T11:37:38.020 に答える