Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Problem with code used in other countries
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
winnie123  
View profile  
 More options Nov 9, 10:56 pm
Newsgroups: microsoft.public.excel.programming
From: winnie123 <winnie...@discussions.microsoft.com>
Date: Mon, 9 Nov 2009 03:56:01 -0800
Local: Mon, Nov 9 2009 10:56 pm
Subject: Problem with code used in other countries
Hi I created a file which basically acts as a price builder.

This has now been distrubted through out our European offices and the USA.

One of the modules alllows the user to select a couple of categories and
then you hit a button and it will create a new workbook with the relevant
pricing information.

It seems that the code reports an error and I am wondering if its due to the
fact that the information is pasted to the new workbook on Sheet1. Obvisously
sheet1 will be  Tabelle1 for Germany and I think its Hoja1 for Spain.

How can I change the macro below to check for the language and then use the
appropirate name for the sheet.

I have seen an example below

Country_Code = Application.International(xlCountryCode)
If Country_Code = 49 Then

For each instance of Sheet1 use Tabelle1

My offending code is below

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Sub CopySelectedColumns()
Dim wbA As Workbook
Dim CopyToWb As Workbook
Dim RateCell As Range
Dim Cur As Range

Dim myRng As Range
Dim myCopy As String
Dim Wks As Worksheet

Set Wks = Worksheets("PriceLists")

myCopy = "P2,Q2"
With Wks
Set myRng = .Range(myCopy)

       If Application.CountA(myRng) <> myRng.Cells.Count Then
            MsgBox "Please fill in Customer Level and Currency!"
            Exit Sub
        End If
        End With

Set wbA = ThisWorkbook
SelectedCol = Range("P2").Value
fCol = Range("B1:N1").Find(what:=SelectedCol, _
Lookat:=xlWhole).Column

Set CopyToWb = Workbooks.Add
'("\\Mcuk-adc\Sales\Prices\PriceTemp.xlt")
Set RateCell = wbA.Worksheets("PriceLists").Range("R2")
Set Cur = wbA.Worksheets("PriceLists").Range("Q2")

wbA.Worksheets("PriceLists").Columns(1).Copy _
CopyToWb.Worksheets("Sheet1").Range("A1")
wbA.Worksheets("PriceLists").Columns(fCol).Copy _
CopyToWb.Worksheets("Sheet1").Range("B1")
CopyToWb.Worksheets("Sheet1").Range("A2") = _
fOSUserName & ", " & Now()

'Do
Customer = InputBox("Enter customer name", "Regards, EW")
'Loop Until Customer <> ""
If Customer = False Then
MsgBox "Ok, try later"
 ActiveWindow.Close savechanges:=False

End If

If Customer = True Then
Else
CopyToWb.Worksheets("Sheet1").Range("A1") = Customer

LastRow = CopyToWb.Worksheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Row

Cur.Copy
CopyToWb.Worksheets("Sheet1").Range("B2").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

RateCell.Copy
CopyToWb.Worksheets("Sheet1").Range("B2:B" & LastRow).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlMultiply, SkipBlanks:= _
True, Transpose:=False
Application.CutCopyMode = False

If Range("B2").Text = "EUR" Then
Range("B4:B114").Select
    Selection.NumberFormat = "[$€-1809]#,##0.00"
    Range("A1").Select
End If

If Range("B2").Text = "USD" Then
Range("B4:B114").Select
    Selection.NumberFormat = "[$$-409]#,##0.00"
    Range("A1").Select
End If

If Range("B2").Text = "AUD" Then
Range("B4:B114").Select
    Selection.NumberFormat = "[$AUD] #,##0.00"
    Range("A1").Select
End If

Application.Run "'Price Quote3.xls'! delete_zero"

'Application.Dialogs(xlDialogFormatNumber).Show

Range("B1").Select
Selection.ClearContents

'Do
SaveAsFilename = Application.GetSaveAsFilename _
(fileFilter:="Excel Files (*.xls), *.xls")
'Loop Until SaveAsFilename <> False

If SaveAsFilename = False Then
        MsgBox "Ok, try later"  'user hit cancel
        ActiveWindow.Close savechanges:=False
        Exit Sub
    End If

CopyToWb.SaveAs Filename:=SaveAsFilename
End If

CopyToWb.Close 'Remove this line if the new workbook shall remain open
'End If
'End If
End Sub

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

Please can you advise/help me.

Thank you

Winnie


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel  
View profile  
 More options Nov 9, 11:45 pm
Newsgroups: microsoft.public.excel.programming
From: joel <joel.41d...@thecodecage.com>
Date: Mon, 9 Nov 2009 12:45:50 +0000
Local: Mon, Nov 9 2009 11:45 pm
Subject: Re: Problem with code used in other countries

I looks like you are adding a template that has only one sheet called
"Sheet1".  I would refere to the sheet by the position in the workbook
being the 1st tab and use sheets(1) instead of Sheets("Sheet1").

--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=152313

[url=&quot;http://www.thecodecage.com"]Microsoft Office Help[/url]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GB  
View profile  
 More options Nov 10, 12:10 am
Newsgroups: microsoft.public.excel.programming
From: GB <G...@discussions.microsoft.com>
Date: Mon, 9 Nov 2009 05:10:02 -0800
Local: Tues, Nov 10 2009 12:10 am
Subject: RE: Problem with code used in other countries
Although it appears that you are attempting to make your code robust enough
to account for all of the potential identifications that Microsoft has made
for the first created sheet (in English "Sheet1") I would recommend that you
take control of the program and create your own new "sheet1" and call it
whatever you like.  This way if you write any form of instruction to use your
program you can be assured that the sheet you are referring to in your
instruction exists as you describe it.

Basically this would be accomplished by creating a new worksheet and
capturing the created worksheet as a variable, then reidentifying the name of
the newly created sheet to the name you want.  Of course you may want to
verify that the named sheet exists already.  (Yet another factor you could
simply adapt/adopt in your code).

If Sheet1 doesn't exist, create a new worksheet and call it Sheet1.  

A number of ways to go about it, but personally, I wouldn't go through the
trouble of identifying the potentially unknown number of languages that
Microsoft has used to call Sheet1 especially if they expand to adopt a new
language and you have to then modify your code to identify it.

If you do decide to use various international languages, then I can think of
a couple of ways to address returning the language and using it the way you
are wanting.  I would use a function that returns the sheet name of the
language and then depending on the work level of the program, either
substitute each use of "Sheet1" with a reference to the function, or use a
variable in every function/sub that is set to the value of that function.  I
deter using a global value that is expected to remain memory resident for the
entirety of the programs use, as I have come across too many instances where
that value is "forgotten" and the entire code crashes. (Sometimes "lost" as a
result of debugging an error in the code.)

My two cents worth if any help.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
winnie123  
View profile  
 More options Nov 10, 12:21 am
Newsgroups: microsoft.public.excel.programming
From: winnie123 <winnie...@discussions.microsoft.com>
Date: Mon, 9 Nov 2009 05:21:01 -0800
Local: Tues, Nov 10 2009 12:21 am
Subject: RE: Problem with code used in other countries
Hi,

So when I add a new workbook I could also add a worksheet named "Prices"  
and paste to the "Prices" sheet instead of Sheet1?

Would that work??

Many thanks
Winnie


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GB  
View profile  
 More options Nov 10, 12:30 am
Newsgroups: microsoft.public.excel.programming
From: GB <G...@discussions.microsoft.com>
Date: Mon, 9 Nov 2009 05:30:01 -0800
Local: Tues, Nov 10 2009 12:30 am
Subject: RE: Problem with code used in other countries
Yup.  Simple as that.

Certainly there may still be other worksheets in the workbook, and whether
you keep them or delete them is up to you.  There is no hard standard as to
how many "other" sheets will be there.  I think the default is 3; however,
that can be changed for each user by the user/administrator.  

Create workbook
Create worksheet
change name of new worksheet to "Prices"
Use "Prices" in place of "Sheet1" in your code.

Then somehow tell the "world" what "Prices" means so that they can interpret
in their native language.

Sorry, haven't written the code to do it, but yes, it will work just like
that.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
winnie123  
View profile  
 More options Nov 10, 12:51 am
Newsgroups: microsoft.public.excel.programming
From: winnie123 <winnie...@discussions.microsoft.com>
Date: Mon, 9 Nov 2009 05:51:01 -0800
Local: Tues, Nov 10 2009 12:51 am
Subject: RE: Problem with code used in other countries
Yes as simple as that.

Many thanks

Just tried it on our German office and all is ok now.

Just need to resend my file out now to the rest of the world.

Best Regards
Winnie


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Wilson  
View profile  
 More options Nov 10, 12:48 am
Newsgroups: microsoft.public.excel.programming
From: Sam Wilson <SamWil...@discussions.microsoft.com>
Date: Mon, 9 Nov 2009 05:48:01 -0800
Local: Tues, Nov 10 2009 12:48 am
Subject: RE: Problem with code used in other countries
Hi,

Rather than referring to Worksheets("Sheet1") you can refer to Worksheets(0)
and that's universal.

Sam


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google