Home > Software engineering >  Vb export spreadsheet prompt "the method of object range _worksheet failure"
Vb export spreadsheet prompt "the method of object range _worksheet failure"

Time:10-14

-- -- -- -- -- -- -- is derived for the first time no problem, and then export the second prompt when "the method of object range _worksheet failure"
-- -- -- -- -- -- -- -- -- -- in the code for mf1 mshflexgrid control -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


Private Sub Command1_Click ()

Dim TempExcel As Excel. Application
Dim TempSheet As Excel. The Worksheet
Dim intI As Integer
Dim intJ As Integer

If mf1. Rows & gt; 1 Then
The Set TempExcel=New Excel. Application
TempExcel. Application. The Visible=True
TempExcel. Workbooks. The Add (1)
The Set TempSheet=TempExcel. ActiveWorkbook. ActiveSheet

With TempExcel. ActiveCell. Characters (Start:=1, Length:=26). The Font
.name="tahoma"
. FontStyle="bold"
. Size=18
'Height=22
The Strikethrough=False
The Superscript=False
The Subscript=False
. OutlineFont=False
The Shadow=True
'Underline=xlUnderlineStyleNone
. ColorIndex=xlAutomatic
End With

For the intI=0 To mf1. Rows 1
For the intJ=0 To mf1. Cols - 1
TempSheet. Cells (intJ intI + 4, + 1)=mf1. TextMatrix (intI, the intJ)
Next intJ
Next intI
After TempSheet. Application. DisplayAlerts=False 'export mistakes don't tip

TempSheet. Cells (1, 1)=Label1. The Caption & amp; Label2. Caption
TempSheet. Range (" A1: P1 "). The MergeCells=True
TempSheet. Range (" A1: A1 "). The HorizontalAlignment=xlCenter


TempSheet. Cells (2, 1)=Label3. The Caption & amp; Combo2. Text & amp; Space (15) & amp; Label5. Caption & amp; Label4. Caption & amp; Space (15) & amp; Label6. Caption & amp; Label7. Caption & amp; Space (15) & amp; Label8. Caption & amp; Label9. Caption & amp; Space (15) & amp; Label10. Caption & amp; Label11. Caption
TempSheet. Range (A2: "P2"). The MergeCells=True
TempSheet. Range (" A2: A2 "). The HorizontalAlignment=xlCenter

TempSheet. Range (" A4: A6). MergeCells=True
TempSheet. Range (" i2: I6.) MergeCells=True
TempSheet. Range (" J4: J6 "). The MergeCells=True
TempSheet. Range (" K4: K6 "). The MergeCells=True
TempSheet. Range (" L4: L6). MergeCells=True
TempSheet. Range (" the M4: M6 "). The MergeCells=True
TempSheet. Range (" N4 interchange: N6 "). The MergeCells=True
TempSheet. Range (" m1: O6). MergeCells=True
TempSheet. Range (" P4, P6). MergeCells=True
TempSheet. Columns (A: "N"). The AutoFit

TempSheet. Range (A: "P"). The HorizontalAlignment=xlCenter

TempSheet. Range (Cells (4, 1), Cells (mf1. Rows + 3, 16)). The Borders. Graphics.linestyle=xlContinuous
TempSheet. Cells (mf1. Rows + 6, 1)=Text2. Text

The Else
MsgBox "no data can be exported," vbOKOnly + vbExclamation, "warning"
The Exit Sub
End the If


End Sub

CodePudding user response:

Does anyone know? His crown,

CodePudding user response:

Save as. CSV format?

CodePudding user response:

Didn't do the second export is an error, save,

CodePudding user response:

Of 123 great god, help me to solve the ~ ~ ~ ~ ~ a help
  • Related