Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default From variable to excel constant

In an excel sheet I'm allowing users to pick from dropdown whether they want
to print in xlPortrait or xlLandscape. It's not feasible to go directly to
Page setup because this page setup that we are applying is for another file.

However, when I read this choice to a variable and setting
pagesetup.orientation to this variable, it doesn't recognize it. This is
because xlPortrait should not be a text, but a constant.

Is there a formula to convert the string to constant? I must allow user to
do the selection in the worksheet.

Thanks,
Carmen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default From variable to excel constant

Try not to apply the text xlPortrait, but the integer of this
constant.

xlPortrait = 1
xlLandscape = 2

hth

Carlo

On Dec 6, 11:11 am, Carmen wrote:
In an excel sheet I'm allowing users to pick from dropdown whether they want
to print in xlPortrait or xlLandscape. It's not feasible to go directly to
Page setup because this page setup that we are applying is for another file.

However, when I read this choice to a variable and setting
pagesetup.orientation to this variable, it doesn't recognize it. This is
because xlPortrait should not be a text, but a constant.

Is there a formula to convert the string to constant? I must allow user to
do the selection in the worksheet.

Thanks,
Carmen


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default From variable to excel constant

xlPortrait is a number and can't be treated as text.. This means it can't be
combined into a text string and can't be inside a double quoted string. It
also can't be selectect be inside a textbox.

You can do something like this

From a drop down box put Portriat or Landscape

select case Range("A1") 'or a textbox which has Portriat or Landscape
case "Portrait"
printmode = xlPortrait
case "Landscape"
printmode = xlLandscape
end select

pagesetup.orientation = printmode

or
select case Range("A1") 'or a textbox which has Portriat or Landscape
case "Portrait"
pagesetup.orientation = xlPortrait
case "Landscape"
pagesetup.orientation = xlLandscape
end select

The use printmode which is a number in your print command.

"Carmen" wrote:

In an excel sheet I'm allowing users to pick from dropdown whether they want
to print in xlPortrait or xlLandscape. It's not feasible to go directly to
Page setup because this page setup that we are applying is for another file.

However, when I read this choice to a variable and setting
pagesetup.orientation to this variable, it doesn't recognize it. This is
because xlPortrait should not be a text, but a constant.

Is there a formula to convert the string to constant? I must allow user to
do the selection in the worksheet.

Thanks,
Carmen

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
subtract a variable no. of mos. from a constant date? in excel Dennis Excel Discussion (Misc queries) 5 July 19th 07 01:50 PM
How to average one constant # to variable #s? A1:A2 A1:A3 A1:A4 Colfax Excel Worksheet Functions 1 March 2nd 06 02:49 AM
Variable Acting Like a Constant? George Boynton Excel Programming 2 October 14th 05 04:06 PM
How to declare variable as Excel constant? John Wirt[_6_] Excel Programming 2 August 22nd 04 05:41 PM
Excel application: Summing several terms (some constant, some variable) David Excel Programming 1 August 12th 03 01:09 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"