Private Sub CreateInvoice_Click()
1。这是为了清空需要填写的发票的所有单元格。
Range("B10").Value = TextBox1.Text
Range("B11").Value = TextBox2.Text
Range("B12").Value = TextBox3.Text
Range("A15").Value = TextBox4.Text
Range("E15").Value = TextBox5.Text
Range("I15").Value = TextBox6.Text
Range("G15").Value = TextBox7.Text
Range("D20").Value = TextBox8.Text
Range("C20").Value = TextBox9.Text
Range("H20").Value = TextBox10.Text
Range("C32").Value = TextBox11.Text
Range("I32").Value = TextBox12.Text
Range("I40").Value = TextBox13.Text
Range("J7") = Date
Dim reply As String
reply = "yes"
Dim row As Long
row = 21
Dim path As String
path = "C:\Invoices\"
Dim mydate As String
mydate = Date
mydate = Format(mydate, "dd_mm_yyyy")
Do While reply = "yes" Or reply = "y"
reply = InputBox("Do you wish to add another item to the invoice? yes/y for
yes and no/n for no", "Add more items?")
If reply = "no" Or reply = "n" Then
2。这是保存代码(我不确定它是否正确,因为我是新手,但我假设是微型启用的Excel,它是我输入数据的默认excel,不保存发票退出时的数字)我试图在这里放置“ActiveWorkbook.Close savechanges:= True”,但仍然不起作用。
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=path & Range("J8").Value & "-" & mydate,
FileFormat:=51
Application.DisplayAlerts = True
ActiveWorkbook.Close savechanges:=False
Else
QTY = InputBox("Please enter the quantity of next item ya habeeb.", "Enter
Quantity")
Cells(row, 3) = QTY
ItemName = InputBox("Please Enter the Name of this item habeeb", "Enter Item
Name")
Cells(row, 4) = ItemName
ItemPrice = InputBox("Please Enter the price of the item.", "Enter Item
Price")
Cells(row, 8) = ItemPrice
ServiceDescription = InputBox("Please enter the next service
description.", "Enter Service Description")
Cells(33, 3) = ServiceDescription
ServicePrice = InputBox("Please Enter the service price habeeb", "Enter
Service Price")
Cells(33, 9) = ServicePrice
End If
row = row + 1
Loop
End Sub
答案 0 :(得分:0)
如果您在下一行继续执行代码,则需要执行以下操作:
ThisWorkbook.SaveAs Filename:=path & Range("J8").Value & "-" & mydate _
FileFormat:=51
然而,您的实际问题是.SaveAs
您的主工作簿,因此您的主工作簿永远不会保存,只会保存在发票工作簿中。
我的建议是始终将.Copy
Sheet
所需的Workbook
(如果多次将其全部复制)到新的.Save
和Workbook
dim wb as Workbook
Set wb = Workbooks("name here.xlsm")
wb.Worksheets("Name Here").Copy
Activeworkbook.SaveAs Filename:=path & Range("J8").Value & "-" & mydate _
FileFormat:=51
'Close Invoice wb
ActiveWorkbook.Close SaveChanges:=False
'Close main wb
wb.Close SaveChanges:=True
<meta property="al:android:url" content="http://jakubsapp/login" />
1}}。
代码示例:
<scheme>://<host>:<port>[<path>|<pathPrefix>|<pathPattern>]