
Sub TuttaTabella1()
Application.ScreenUpdating = False
Dim mioWord As New Word.Application, mioDoc As Word.Document
Dim ultima_riga As Long
'(*.xls; *.xlsx; *.xlsm),*.xls; *xlsx; *.xlsm", , "Selezionare il file")
Dim PercorsoFile As String
PercorsoFile = Application.GetOpenFilename("File Microsoft Word(*.doc; *.docx),*.doc; *.docx", , "Ricerca documenti Word")
If PercorsoFile = "Falso" Then
Exit Sub
End If
'PercorsoFile = Application.GetOpenFilename("File Microsoft Word(*.docx),*.docx", , "Ricerca documenti Word")
'Percorso = Application.GetOpenFilename("Microsoft Word (*.doc), *.doc")
mioWord.Visible = False
If PercorsoFile <> "" Then
Documents.Open Filename:=PercorsoFile, OpenAndRepair:=True
End If
''''''''''''''''mioWord.Documents.Open "C:UsersNicolaDesktop est.doc"
'Set mioDoc = mioDoc.Activate
MsgBox ("ok")
'mioWord.Documents.Open
'mioDoc.Activate
Set mioDoc = mioWord.ActiveDocument
mioDoc.Tables(1).Range.Copy
ultima_riga = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
If ultima_riga = 1 Then ultima_riga = 0
ActiveSheet.Cells(ultima_riga + 1, 1).PasteSpecial xlPasteValues
[A1].CurrentRegion.Columns.AutoFit
mioDoc.Close
mioWord.Quit
Set mioWord = Nothing
MsgBox "Ho terminato la copia dei dati."
Application.ScreenUpdating = True
End Sub |
Sub TuttaTabella1()
Application.ScreenUpdating = False
Dim mioWord As New Word.Application, mioDoc As Word.Document
Dim ultima_riga As Long
'(*.xls; *.xlsx; *.xlsm),*.xls; *xlsx; *.xlsm", , "Selezionare il file")
Dim PercorsoFile As String
PercorsoFile = Application.GetOpenFilename("File Microsoft Word(*.doc; *.docx),*.doc; *.docx", , "Ricerca documenti Word")
If PercorsoFile = "Falso" Then
Exit Sub
End If
'PercorsoFile = Application.GetOpenFilename("File Microsoft Word(*.docx),*.docx", , "Ricerca documenti Word")
'Percorso = Application.GetOpenFilename("Microsoft Word (*.doc), *.doc")
mioWord.Visible = False
'Documents.Open Filename:=PercorsoFile , OpenAndRepair:=True
'mioWord.Documents.Open "C:UsersNicolaDesktopAA.doc"
'Set mioDoc = mioDoc.Activate
'MsgBox ("ok")
mioWord.Documents.Open (PercorsoFile)
'mioDoc.Activate
Set mioDoc = mioWord.ActiveDocument
mioDoc.Tables(1).Range.Copy
ultima_riga = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
If ultima_riga = 1 Then ultima_riga = 0
ActiveSheet.Cells(ultima_riga + 1, 1).PasteSpecial xlPasteValues
[A1].CurrentRegion.Columns.AutoFit
mioDoc.Close
mioWord.Quit
Set mioWord = Nothing
MsgBox "Ho terminato la copia dei dati."
Application.ScreenUpdating = True
End Sub |
Sub TuttaTabella()
'COPIA SIA l' IntestazionE CHE I DATI
Dim mioWord As New Word.Application
mioWord.Visible = True
mioWord.Documents.Open "C:Documents and Settingsx880588DesktopEB.doc"
Dim mioDoc As Document
Set mioDoc = mioWord.Documents(1)
Set Tabella = mioDoc.Tables(1)
Dim Riga As Row, Cella As Cell, Valore As String
Dim i As Integer, j As Integer
For Each Riga In Tabella.Rows
i = i + 1
For Each Cella In Riga.Cells
j = j + 1
Valore = Cella.Range
Valore = Left(Valore, Len(Valore) - 2) '(2)
If Right(Valore, 1) = "%" Then
Valore = Left(Valore, Len(Valore) - 1)
End If
If IsNumeric(Valore) Then
If InStr(1, Valore, ",") Then
Mid(Valore, InStr(1, Valore, ",")) = "."
End If
Range("A1")(i, j).Value = Val(Valore)
Else
Range("A1")(i, j).Value = Valore
End If
Next
j = 0
Next
' Adatta larghezza colonne
With Range("A1")
Range(.Cells(1, 1), .End(xlToRight)).Columns.AutoFit
End With
mioDoc.Close
mioWord.Quit
Set mioWord = Nothing
End Sub
|
ultima_riga = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
If ultima_riga = 1 Then ultima_riga = 0
ActiveSheet.Cells(ultima_riga + 1, 1).PasteSpecial xlPasteValues
'nel tuo codice, prima di For Each riga aggiungi queste due righe:
i = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
If ultima_riga = 1 Then ultima_riga = 0
For Each riga in Tabella.Rows
'segue il resto del codice |
Sub TuttaTabella()
'Copia sia l' Intestazione che i dati
Dim mioWord As New Word.Application
mioWord.Visible = True
Dim PercorsoFile As String
PercorsoFile = Application.GetOpenFilename("File Microsoft Word(*.doc; *.docx),*.doc; *.docx", , "Ricerca documenti Word")
If PercorsoFile = "Falso" Then
Exit Sub
End If
Dim mioDoc As Document
mioWord.Documents.Open (PercorsoFile)
Set mioDoc = mioWord.ActiveDocument
Set Tabella = mioDoc.Tables(1)
Dim Riga As Row, Cella As Cell, Valore As String
Dim i As Integer, j As Integer
i = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
If ultima_riga = 1 Then ultima_riga = 0
For Each Riga In Tabella.Rows
i = i + 1
'segue il resto del codice
For Each Cella In Riga.Cells
j = j + 1
Valore = Cella.Range
Valore = Left(Valore, Len(Valore) - 2) '(2)
If Right(Valore, 1) = "%" Then
Valore = Left(Valore, Len(Valore) - 1)
End If
If IsNumeric(Valore) Then
If InStr(1, Valore, ",") Then
Mid(Valore, InStr(1, Valore, ",")) = "."
End If
Range("A1")(i, j).Value = Val(Valore)
Else
Range("A1")(i, j).Value = Valore
End If
Next
j = 0
Next
' Adatta larghezza colonne
With Range("A1")
Range(.Cells(1, 1), .End(xlToRight)).Columns.AutoFit
End With
mioDoc.Close
mioWord.Quit
Set mioWord = Nothing
End Sub |
