Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Importar datos de excel a excel sin abrir archivo

publicado

Buenas tardes,

Estoy haciendo un programa y pretendo importar los datos de distintas hojas de un archivo excel a otro pero sin que se me abra el archivo.

Tengo este código que he sacado grabando una macro, pero cuando lo pego a mi codigo y ejecuto no consigo que importe los datos

With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Seleccionar arxiu 'Estudi'"
.AllowMultiSelect = False
.InitialFileName = "\*Estudio_CD*"

result = .Show
If (result <> 0) Then
RutaLBT = Trim(.SelectedItems.Item(1))

End If
End With

RutaArrel = Left(RutaLBT, Len(RutaLBT) - 14)

MsgBox (RutaLBT)

ActiveWorkbook.Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "dades"

ActiveWorkbook.Connections.AddFromFile "RutaLBT"

With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=RutaLBT;Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Databas" _
, _
"e Password="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bu" _
, _
"lk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet" _
, _
" OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support C" _
, _
"omplex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Bypass ChoiceField Val" _
, "idation=False"), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("'Estudio LBT$'")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceConnectionFile = _
"C:\Users\Pau\Documents\Els meus orígens de dades\Estudio_CD_EM18001-04-03 'Estudio LBT$'.odc"
.SourceDataFile = _
"C:\Users\Pau\Desktop\calculs\Estudio_CD_EM18001-04-03.xls"
.ListObject.DisplayName = "Taula_Estudio_CD_EM18001_04_03__Estudio_LBT"
.Refresh BackgroundQuery:=False
End With[/CODE]

Se me queda colgando la importacion...

A ver si alguien me puede ayudar!

Featured Replies

No hay posts para mostrar

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.