---
title: "VBScript related - Excel"
author: "buralin"
date: "2014-02-24T18:21:12Z"
tags: []
categories: ["编程语言"]
slug: "vbscript-related-excel"
draft: false
lastmod: "2014-06-24T15:00:34Z"
id: 2021122
url: "https://buralin.iteye.com/blog/2021122"
---

**1. Excel sample**

Public Const privateKey As String = "c:\\Programs\\RBP Server Manager\\path\\private.ppk"

 

Public Const puttyPath As String = "c:\\Programs\\RBP Server Manager\\path\\PUTTY.EXE"

Public Const winSCPPath As String = "C:\\Programs\\Winscp\_Testlab\\WinSCP\\WinSCP.exe"

 

Sub runPutty()

Dim puttyPath, privateKey, account, server

account = Cells(ActiveCell.Row, 3)

server = Cells(ActiveCell.Row, 2)

Call Shell("""" & puttyPath & """" & " -i " & """" & privateKey & """ " & account & "@" & server, vbNormalFocus)

End Sub

 

Sub runWinSCP()

Dim account, server

account = Cells(ActiveCell.Row, 3)

server = Cells(ActiveCell.Row, 2)

Call Shell(winSCPPath & " scp://" & account & "@" & server & ":22 /privatekey=""" & privateKey & """", vbNormalFocus)

End Sub

 

 **2. get value**

cell(1,1).VALUE

cell(1,1).TEXT

VALUE 属性获取是单元格的真实值，即实际结果。

TEXT 属性获取的是单元格的显示值，就是单元格里显示出来的值。