Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Form Question! 1

Status
Not open for further replies.

CBOIT

IS-IT--Management
Jul 9, 2010
22
US
Okay . . . I have a VBS that uses a series of prompts to acquire information. I would like to simplify it by creating an HTML form to collect the data; but have absolutely no idea on how to do this. Here is the original VBS:

Code:
' Storage Organizer
'
' Application to record boxes in storage shed, and
' print labels to affix to the boxes.
'
' 
' June 25, 2010 
'
' RevC
'


' Declaring the variables
strDate = Date()
strName = InputBox("First and Last Name: ")
strDept = InputBox("Department: ")
strBoxNo = InputBox("Box Number: ")
strContents = InputBox("Contents: ")
strDestroy = InputBox("Destruction Date: ")




'Creating log.
Dim Stuff, logFSO, WriteStuff, dateStamp
strLog =strName & " from " & strDept & " sent box " & strBoxNo & " to the shed on " & strDate & ".  It contained " & strContents & ", and is due for destruction on " & strDestroy & "."
strLog2 =strName & "," & strDept & "," & strBoxNo & "," & strDate & "," & strContents & "," & strDestroy
Set logFSO = CreateObject("Scripting.FileSystemObject")
Set WriteLog = logFSO.OpenTextFile("\\server2006\tech\log\Storage Log.txt", 8, True)
Set WriteLog2 = logFSO.OpenTextFile("\\server2006\tech\log\Storage Log2.csv", 8, True)
WriteLog.WriteLine(strLog)
WriteLog.Close
WriteLog2.WriteLine(strLog2)
WriteLog2.Close
SET WriteLog = NOTHING
SET logFSO = NOTHING


' Binding to Excel object.
Set objExcel = CreateObject("Excel.Application")

'Configuring view during creation.
objExcel.Visible = False

'Opening template.
objExcel.Workbooks.Open("\\server2006\tech\boxlabel\labeltemplate.xlsx")


' Bind to existing worksheet (w1).
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Box Label"


' Populating first portion of spreadsheet (w1).
objSheet.Cells(1, 2).Value =Left(strDept,1)
objSheet.Cells(1, 3).Value =strBoxNo
objSheet.Cells(3, 1).Value =strDate
objSheet.Cells(3, 4).Value =strDestroy

' AutoFit Cells on w1.
objExcel.Range("b2:B4").Select
objExcel.Cells.EntireColumn.AutoFit

' Populate the rest of the worksheet.
objSheet.Cells(5, 1).Value =strName
objSheet.Cells(7, 4).Value =strcontents
objSheet.Cells(6, 1).Value =strDept

' Print w1.
objExcel.ActiveWorkbook.PrintOut

' Close w1, supressing prompt.
objExcel.ActiveWorkbook.Close(False)




'Opening template.
objExcel.Workbooks.Open("\\server2006\tech\boxlabel\reporttemplate.xlsx")


' Bind to existing worksheet (w2).
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Box Inventory"


' Populating first portion of spreadsheet (w2).
objSheet.Cells(1, 2).Value =Left(strDept,1)
objSheet.Cells(1, 3).Value =strBoxNo
objSheet.Cells(3, 2).Value =strDate
objSheet.Cells(5, 2).Value =strName
objSheet.Cells(6, 2).Value =strDept
objSheet.Cells(8, 2).Value =strDestroy
objSheet.Cells(10, 2).Value =strContents + "."


' AutoFit Cells on w2.
objExcel.Range("b2:B4").Select
objExcel.Cells.EntireColumn.AutoFit


' Print w2.
objExcel.ActiveWorkbook.PrintOut

' Close w2, supressing prompt.
objExcel.ActiveWorkbook.Close(False)




' Exit Excel
objExcel.Quit



[∞]MP
 
Since you are using Excel, have you considered a userform and VBA code?

You can use your existing code to write out the log file (your log file code should work as is in Excel VBA) and create a userform to input the required information.
 
jges,
Forgive my ignorance; but waht is a userform?

[∞]MP
 
It is a container for controls (textboxes, labels, command buttons, radio buttons, etc) that you can present to the user for input and/or output.

If you have Excel handy, open it press "alt" + "F11" to get into the VBA design environment and "Insert -> userform". Here you can add controls to create an input form (much like an HTML form, only the design is more drag & drop). Add a command button then double click it to add code that you want to fire when the user presses the button.
 
Very cool. I'll start looking into that.

[∞]MP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top