PC Review


Reply
 
 
Miree
Guest
Posts: n/a
 
      2nd Oct 2008
I have the following code but it is not pasting and i am not sure why, can
anyone help please. Also In the file cells i am copying from there is a
defined list, will this be updated when in the new file when i paste?

Thank you

Sub UpdateDensities()
'Copy this section changing fluid database name for open and close,

' Open the database.
Workbooks.Open "G:\Drilling Fluids Technology\Fluids
Database\FluidDatabaseTemplate.xls"

'Unlock folder denstities page
Windows("FluidDatabaseTemplate.xls").Activate
Sheets("Densities").Select
ActiveSheet.Unprotect Password:="baker"

'Copy and Paste Section

Windows("FluidDatabaseTemplate.xls").Activate
Columns("H:M").Select
Selection.EntireColumn.Hidden = False

Windows("FluidDatabaseMM.xls").Activate
Sheets("Densities").Select
Columns("A:M").Select
Selection.Copy

Windows("FluidDatabaseTemplate.xls").Activate
Columns("A:M").Select
Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False

Columns("H:M").Select
Selection.EntireColumn.Hidden = True

Windows("FluidDatabaseTemplate.xls").Activate
Sheets("Densities").Select
ActiveSheet.Protect Password:="baker"

Windows("FluidDatabaseMM.xls").Activate
Sheets("Extras").Select

'Close Workbook
Application.DisplayAlerts = False
Workbooks("FluidDatabaseTemplate.xls").Close
Application.DisplayAlerts = True

End Sub
 
Reply With Quote
 
 
 
 
Garreth Lombard
Guest
Posts: n/a
 
      2nd Oct 2008
Hi there,

For the code given i dont see any declarations of something being copied or
pasted.
You may want to look into that first and see what happens from there. If you
need help with the copy segment then feel free to ask
--


Thank you and Regards

Garreth Lombard


"Miree" wrote:

> I have the following code but it is not pasting and i am not sure why, can
> anyone help please. Also In the file cells i am copying from there is a
> defined list, will this be updated when in the new file when i paste?
>
> Thank you
>
> Sub UpdateDensities()
> 'Copy this section changing fluid database name for open and close,
>
> ' Open the database.
> Workbooks.Open "G:\Drilling Fluids Technology\Fluids
> Database\FluidDatabaseTemplate.xls"
>
> 'Unlock folder denstities page
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Unprotect Password:="baker"
>
> 'Copy and Paste Section
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = False
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Densities").Select
> Columns("A:M").Select
> Selection.Copy
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("A:M").Select
> Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
>
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = True
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Protect Password:="baker"
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Extras").Select
>
> 'Close Workbook
> Application.DisplayAlerts = False
> Workbooks("FluidDatabaseTemplate.xls").Close
> Application.DisplayAlerts = True
>
> End Sub

 
Reply With Quote
 
Garreth Lombard
Guest
Posts: n/a
 
      2nd Oct 2008
Oops found those statements. Im looking into the matter for you now
--


Thank you and Regards

Garreth Lombard


"Miree" wrote:

> I have the following code but it is not pasting and i am not sure why, can
> anyone help please. Also In the file cells i am copying from there is a
> defined list, will this be updated when in the new file when i paste?
>
> Thank you
>
> Sub UpdateDensities()
> 'Copy this section changing fluid database name for open and close,
>
> ' Open the database.
> Workbooks.Open "G:\Drilling Fluids Technology\Fluids
> Database\FluidDatabaseTemplate.xls"
>
> 'Unlock folder denstities page
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Unprotect Password:="baker"
>
> 'Copy and Paste Section
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = False
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Densities").Select
> Columns("A:M").Select
> Selection.Copy
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("A:M").Select
> Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
>
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = True
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Protect Password:="baker"
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Extras").Select
>
> 'Close Workbook
> Application.DisplayAlerts = False
> Workbooks("FluidDatabaseTemplate.xls").Close
> Application.DisplayAlerts = True
>
> End Sub

 
Reply With Quote
 
Miree
Guest
Posts: n/a
 
      2nd Oct 2008
Figured it out i forgot to write to save the file before closing.

But still need to know if it is possible to update the size of defined lists
from one source to another.

"Miree" wrote:

> I have the following code but it is not pasting and i am not sure why, can
> anyone help please. Also In the file cells i am copying from there is a
> defined list, will this be updated when in the new file when i paste?
>
> Thank you
>
> Sub UpdateDensities()
> 'Copy this section changing fluid database name for open and close,
>
> ' Open the database.
> Workbooks.Open "G:\Drilling Fluids Technology\Fluids
> Database\FluidDatabaseTemplate.xls"
>
> 'Unlock folder denstities page
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Unprotect Password:="baker"
>
> 'Copy and Paste Section
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = False
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Densities").Select
> Columns("A:M").Select
> Selection.Copy
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("A:M").Select
> Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
>
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = True
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Protect Password:="baker"
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Extras").Select
>
> 'Close Workbook
> Application.DisplayAlerts = False
> Workbooks("FluidDatabaseTemplate.xls").Close
> Application.DisplayAlerts = True
>
> End Sub

 
Reply With Quote
 
Garreth Lombard
Guest
Posts: n/a
 
      2nd Oct 2008
Great,

Was going to ask that question next and maybe suggest you save with the
below statement..

Activeworkbook.Save
--


Thank you and Regards

Garreth Lombard


"Miree" wrote:

> Figured it out i forgot to write to save the file before closing.
>
> But still need to know if it is possible to update the size of defined lists
> from one source to another.
>
> "Miree" wrote:
>
> > I have the following code but it is not pasting and i am not sure why, can
> > anyone help please. Also In the file cells i am copying from there is a
> > defined list, will this be updated when in the new file when i paste?
> >
> > Thank you
> >
> > Sub UpdateDensities()
> > 'Copy this section changing fluid database name for open and close,
> >
> > ' Open the database.
> > Workbooks.Open "G:\Drilling Fluids Technology\Fluids
> > Database\FluidDatabaseTemplate.xls"
> >
> > 'Unlock folder denstities page
> > Windows("FluidDatabaseTemplate.xls").Activate
> > Sheets("Densities").Select
> > ActiveSheet.Unprotect Password:="baker"
> >
> > 'Copy and Paste Section
> >
> > Windows("FluidDatabaseTemplate.xls").Activate
> > Columns("H:M").Select
> > Selection.EntireColumn.Hidden = False
> >
> > Windows("FluidDatabaseMM.xls").Activate
> > Sheets("Densities").Select
> > Columns("A:M").Select
> > Selection.Copy
> >
> > Windows("FluidDatabaseTemplate.xls").Activate
> > Columns("A:M").Select
> > Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> > SkipBlanks:= _
> > False, Transpose:=False
> >
> > Columns("H:M").Select
> > Selection.EntireColumn.Hidden = True
> >
> > Windows("FluidDatabaseTemplate.xls").Activate
> > Sheets("Densities").Select
> > ActiveSheet.Protect Password:="baker"
> >
> > Windows("FluidDatabaseMM.xls").Activate
> > Sheets("Extras").Select
> >
> > 'Close Workbook
> > Application.DisplayAlerts = False
> > Workbooks("FluidDatabaseTemplate.xls").Close
> > Application.DisplayAlerts = True
> >
> > End Sub

 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      2nd Oct 2008
Hi

I cleaned up your original code, as you have many steps not needed.

BTW: I don't think it's nessecary to turn off alerts if you save the
workbook before it's closed.

Look at this:

Sub UpdateDensities()
Dim ThisWb As Workbook
Dim dbWB As Workbook

Set ThisWb = ActiveWorkbook
'Copy this section changing fluid database name for open and close,
' Open the database.
Set dbWB = Workbooks.Open("G:\Drilling Fluids Technology\Fluids
Database\FluidDatabaseTemplate.xls")

'Copy and Paste Section
ThisWb.Sheets("Densities").Columns("A:M").Copy

With dbWB.Sheets("Densities")
.Unprotect Password:="baker"
.Sheets("Densities").Columns("H:M").Hidden = False
.Columns("A:M").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
.Columns("H:M").Hidden = True
.Protect Password:="baker"
End With

ThisWb.Sheets("Extras").Select 'Only required if another sheet is active
when this macro is started!

'Close Workbook
Application.DisplayAlerts = False
dbWB.SaveAs '<=== enter path and filename here
dbWB.Close
Application .DisplayAlerts = True
End Sub

HTH
Per

"Miree" <(E-Mail Removed)> skrev i meddelelsen
news:4A182F7A-E02C-437F-A84E-(E-Mail Removed)...
>I have the following code but it is not pasting and i am not sure why, can
> anyone help please. Also In the file cells i am copying from there is a
> defined list, will this be updated when in the new file when i paste?
>
> Thank you
>
> Sub UpdateDensities()
> 'Copy this section changing fluid database name for open and close,
>
> ' Open the database.
> Workbooks.Open "G:\Drilling Fluids Technology\Fluids
> Database\FluidDatabaseTemplate.xls"
>
> 'Unlock folder denstities page
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Unprotect Password:="baker"
>
> 'Copy and Paste Section
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = False
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Densities").Select
> Columns("A:M").Select
> Selection.Copy
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("A:M").Select
> Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
>
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = True
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Protect Password:="baker"
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Extras").Select
>
> 'Close Workbook
> Application.DisplayAlerts = False
> Workbooks("FluidDatabaseTemplate.xls").Close
> Application.DisplayAlerts = True
>
> End Sub


 
Reply With Quote
 
john
Guest
Posts: n/a
 
      2nd Oct 2008
this approach may work:

Sub UpdateDensities()
Dim TPFile As String
Dim TPWB As Workbook
Dim ThisWKB As Workbook
Dim r1 As Range, r2 As Range

Set ThisWKB = ThisWorkbook

Application.ScreenUpdating = False

TPFile = "G:\Drilling Fluids Technology\Fluids
Database\FluidDatabaseTemplate.xls "

' Open the database.
Set TPWB = Workbooks.Open(TPFile, ReadOnly:=False, Password:="")

'set 1st range to copy
Set r1 = ThisWKB.Worksheets("Densities").Columns("A:M")

With TPWB.Worksheets("Densities")
.Unprotect Password:="baker"

'set 2nd range to paste to
Set r2 = .Columns("A:M")

'copy & paste
r1.Copy r2

.Columns("H:M").Hidden = True

.Protect Password:="baker"
End With

'close & save
TPWB.Close True

Application.ScreenUpdating = True
End Sub

--
jb


"Miree" wrote:

> I have the following code but it is not pasting and i am not sure why, can
> anyone help please. Also In the file cells i am copying from there is a
> defined list, will this be updated when in the new file when i paste?
>
> Thank you
>
> Sub UpdateDensities()
> 'Copy this section changing fluid database name for open and close,
>
> ' Open the database.
> Workbooks.Open "G:\Drilling Fluids Technology\Fluids
> Database\FluidDatabaseTemplate.xls"
>
> 'Unlock folder denstities page
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Unprotect Password:="baker"
>
> 'Copy and Paste Section
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = False
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Densities").Select
> Columns("A:M").Select
> Selection.Copy
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Columns("A:M").Select
> Selection.pasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
>
> Columns("H:M").Select
> Selection.EntireColumn.Hidden = True
>
> Windows("FluidDatabaseTemplate.xls").Activate
> Sheets("Densities").Select
> ActiveSheet.Protect Password:="baker"
>
> Windows("FluidDatabaseMM.xls").Activate
> Sheets("Extras").Select
>
> 'Close Workbook
> Application.DisplayAlerts = False
> Workbooks("FluidDatabaseTemplate.xls").Close
> Application.DisplayAlerts = True
>
> End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AES encryption seems to be broken (MS Sample code!) Lothar Behrens Microsoft C# .NET 0 4th Oct 2010 09:25 AM
Code Anaylsis broken in VS2008 Arnie Microsoft Dot NET 0 8th Feb 2008 06:18 PM
broken code? =?Utf-8?B?LSBBbGV4?= Microsoft Access 0 4th Jul 2006 01:26 PM
Broken references, Please check my code ! Javier G via AccessMonster.com Microsoft Access VBA Modules 6 10th Oct 2005 11:33 AM
MSDN Code Broken for VB.NET Bill Smith Microsoft ASP .NET 3 30th Jan 2005 09:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 PM.