Home > Software engineering > I want to write a vb modified cell line height and column width (in CM) of small programs
I want to write a vb modified cell line height and column width (in CM) of small programs
Time:10-25
Option Explicit Private Sub cmd1_Click () Dim xlsxapp As Excel. Application Dim xlsxbook As Excel. The Workbook Dim xlsxsheet As Excel. The Worksheet Dim sheetname, excelpath As String Dim rowheight, columnwidth As Single 'statement b for Single precision The Set xlsxapp=CreateObject (" Excel. Application ") 'create Excel object Xlsxapp. Visible=False 'set the EXCEL object Visible or invisible Sheetname=txt3. Text Excelpath=txt4. Text The Debug. Print excelpath The Debug. Print sheetname The Set xlsxbook=xlsxapp. Workbooks. Open (excelpath) 'Open the EXCEL workpiece book file already exists, must Open the EXCEL with application a folder The Set xlsxsheet=xlsxbook. Worksheets (sheetname) Xlsxbook. Worksheets (sheetname). Activate MsgBox "please select a need to change the column width cross cell line height" If txt1. Text & lt;> "" Then Rowheight=CSng (txt1. Text) 'the text1. The value of the Text is converted into a single precision number and assign a value to the rowheight Rowheight=rowheight * 28.45 Xlsxbook. Xlsxsheet. Rows (ActiveCell.) rowheight=rowheight End the If If txt2. Text & lt;> "" Then Columnwidth=CSng (txt2. Text) Columnwidth columnwidth *=83.8/1.9 Xlsxbook. Xlsxsheet. Rows (ActiveCell.) columnwidth=columnwidth End the If The Set xlsxbook=Nothing The Set xlsxsheet=Nothing Xlsxapp. Quit End Sub Private Sub txt4_Click () CommonDialog1. Action=1 CommonDialog1. Filter="EXCEL (*. XLSX) | (*. XLSX)" Txt4. Text=CommonDialog1. FileName End Sub
Which always xlsxbook. Xlsxsheet. Rows (ActiveCell.) columnwidth=columnwidth that there is an error code, strives for the guidance, the couple!
CodePudding user response:
I work with form get file path name and table name! Vb can automatically get an open path and activation of excel table work table name? In addition, vb and vba syntax what are not the same!