【发布时间】:2020-01-31 22:46:54
【问题描述】:
我需要一种将 VBA Excel 宏转换为 Google 表格的方法,下面的代码将数据列表传输到发票,然后将其另存为 PDF。我在网上搜索了翻译,但没有找到。如果有人知道,或者有人可以翻译这个。
Private Sub CommandButton1_Click()
'define value
Dim customer As String
Dim invoicenumber As Long
Dim invoicedate As Long
Dim path As String
Dim myfilename As String
Dim rate As Long
Dim r As Long
'define our last row
lastrow = Sheets("Dispatch1").Range("O" & Rows.Count).End(xlUp).Row
' start at row 5
r = 5
For r = 5 To 10
If Cells(r, 1).Value = "done" Then GoTo nextrow
invoicedate = Sheets("Dispatch1").Cells(r, 5).Value
rate = Sheets("Dispatch1").Cells(r, 15).Value
invoicenumber = Sheets("Dispatch1").Cells(r, 17).Value
Amount = Sheets("Dispatch1").Cells(r, 19).Value
Application.DisplayAlerts = False
Sheets("invoiceblank").Select
' map the variables to invoice worksheet data
ActiveSheet.Range("F4").Value = invoicedate
ActiveSheet.Range("G4").Value = invoicenumber
ActiveSheet.Range("F18").Value = rate
path = "C:\Users\Dell\Desktop\feb"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
fileName:="C:\Users\Dell\Desktop\aa new trucking\feb\" & _
ActiveSheet.Range("G4 ").Value & _
Worksheets("Customers").Range("A1").Value & _
ActiveSheet.Range("A16").Value & ".pdf", _
OpenAfterPublish:=False
'our label next row. Labels have a colon after their name
nextrow:
Next r
End Sub
【问题讨论】:
-
excel 是 VBA,google 是 Java,两种不同的语言。它们没有可比性。
-
谷歌表格是否运行 vba 宏?如果不是,您需要将其写在等效的 google 表格中 - 好消息是您有一个先机:逻辑或基本结构已经存在。
-
这里有几个关于这个的问题,请阅读它们。这只是一个和其他可能更相关:stackoverflow.com/q/46648022/4961700
-
简短回答:没有翻译器,您必须自己手动翻译。 • “……或者如果有人可以翻译这个” 请注意,Stack Overflow 不是免费的翻译/编码服务。因此,您必须自己开始。如果遇到卡住或错误,您可以针对卡住的具体点提出问题。
标签: javascript excel vba google-apps-script google-sheets