Hello all,
I am trying to programmaticall y change the orientation of a MS Word Document
to landscape. I must be doing something wrong cause it does not work ... can
anybody help me with this?
Code is below ....
Much obliged ...
Ronny Sigo
Dim appWD As Object
Dim myDoc As Object
Dim sSavestring As String
Set appWD = CreateObject("W ord.Application ")
appWD.Visible = True
With appWD
Set myDoc = .Documents.Add
.Documents(1).A ctivate
With .ActiveDocument .PageSetup
.Orientation = wdOrientLandsca pe
End With
.WindowState = wdWindowStateMa ximize
With .Selection
cm = 1
.PageSetup.Left Margin = CentimetersNaar Punten(cm)
.PageSetup.Righ tMargin = CentimetersNaar Punten(cm)
.PageSetup.TopM argin = CentimetersNaar Punten(cm)
.ParagraphForma t.LeftIndent = 0
.ParagraphForma t.LineSpacing = 13
.Font.Name = "Arial"
.Font.Color = vbRed
.Font.Italic = True
.InlineShapes.A ddPicture FileName:= _
"\\MyPath\Myfil e.bmp", LinkToFile:=Fal se, _
SaveWithDocumen t:=True
.insertafter Text:=" Lijst alle contacten de4000 "
.Font.Size = 24
.Font.Bold = True
.Collapse Direction:=wdCo llapseEnd
.insertafter Text:=vbCrLf
.insertafter Text:=vbTab & vbTab & vbTab
.insertafter Text:="Bestand aangemaakt op: "
.Font.Size = 12
.Font.Bold = False
.insertafter Text:=Date & vbCr & vbCr & vbCr
.Collapse Direction:=wdCo llapseEnd
End With
sSavestring = "\\MyPath\MyFil e" & Year(Date) & "-" & Month(Date)
& "-" & _
Day(Date)
myDoc.SaveAs FileName:=sSave string
End With
'appWD.Quit
Set appWD = Nothing
If theError = 429 Then appWD.Quit
Set appWD = Nothing 4 17677
"Ronny Sigo" <roon ad skynet.be> wrote in message news:<41******* *************** *@news.skynet.b e>... Hello all, I am trying to programmaticall y change the orientation of a MS Word Document to landscape. I must be doing something wrong cause it does not work ... can anybody help me with this? Code is below .... Much obliged ... Ronny Sigo
Dim appWD As Object Dim myDoc As Object Dim sSavestring As String Set appWD = CreateObject("W ord.Application ") appWD.Visible = True With appWD Set myDoc = .Documents.Add .Documents(1).A ctivate With .ActiveDocument .PageSetup .Orientation = wdOrientLandsca pe End With .WindowState = wdWindowStateMa ximize With .Selection cm = 1 .PageSetup.Left Margin = CentimetersNaar Punten(cm) .PageSetup.Righ tMargin = CentimetersNaar Punten(cm) .PageSetup.TopM argin = CentimetersNaar Punten(cm) .ParagraphForma t.LeftIndent = 0 .ParagraphForma t.LineSpacing = 13 .Font.Name = "Arial" .Font.Color = vbRed .Font.Italic = True .InlineShapes.A ddPicture FileName:= _ "\\MyPath\Myfil e.bmp", LinkToFile:=Fal se, _ SaveWithDocumen t:=True .insertafter Text:=" Lijst alle contacten de4000 " .Font.Size = 24 .Font.Bold = True .Collapse Direction:=wdCo llapseEnd .insertafter Text:=vbCrLf .insertafter Text:=vbTab & vbTab & vbTab .insertafter Text:="Bestand aangemaakt op: " .Font.Size = 12 .Font.Bold = False .insertafter Text:=Date & vbCr & vbCr & vbCr .Collapse Direction:=wdCo llapseEnd End With sSavestring = "\\MyPath\MyFil e" & Year(Date) & "-" & Month(Date) & "-" & _ Day(Date) myDoc.SaveAs FileName:=sSave string End With 'appWD.Quit Set appWD = Nothing If theError = 429 Then appWD.Quit Set appWD = Nothing
When I record a macro to change the orientation, Word changes several
PageSetup parameters instead of just .Orientation. Perhaps you could
try including all of these and then try eliminating them one by one
until you have the smallest set necessary.
James A. Fortune
"Ronny Sigo" <roon ad skynet.be> wrote in message news:<41******* *************** *@news.skynet.b e>... Hello all, I am trying to programmaticall y change the orientation of a MS Word Document to landscape. I must be doing something wrong cause it does not work ... can anybody help me with this? Code is below .... Much obliged ... Ronny Sigo
Dim appWD As Object Dim myDoc As Object Dim sSavestring As String Set appWD = CreateObject("W ord.Application ") appWD.Visible = True With appWD Set myDoc = .Documents.Add .Documents(1).A ctivate With .ActiveDocument .PageSetup .Orientation = wdOrientLandsca pe End With .WindowState = wdWindowStateMa ximize With .Selection cm = 1 .PageSetup.Left Margin = CentimetersNaar Punten(cm) .PageSetup.Righ tMargin = CentimetersNaar Punten(cm) .PageSetup.TopM argin = CentimetersNaar Punten(cm) .ParagraphForma t.LeftIndent = 0 .ParagraphForma t.LineSpacing = 13 .Font.Name = "Arial" .Font.Color = vbRed .Font.Italic = True .InlineShapes.A ddPicture FileName:= _ "\\MyPath\Myfil e.bmp", LinkToFile:=Fal se, _ SaveWithDocumen t:=True .insertafter Text:=" Lijst alle contacten de4000 " .Font.Size = 24 .Font.Bold = True .Collapse Direction:=wdCo llapseEnd .insertafter Text:=vbCrLf .insertafter Text:=vbTab & vbTab & vbTab .insertafter Text:="Bestand aangemaakt op: " .Font.Size = 12 .Font.Bold = False .insertafter Text:=Date & vbCr & vbCr & vbCr .Collapse Direction:=wdCo llapseEnd End With sSavestring = "\\MyPath\MyFil e" & Year(Date) & "-" & Month(Date) & "-" & _ Day(Date) myDoc.SaveAs FileName:=sSave string End With 'appWD.Quit Set appWD = Nothing If theError = 429 Then appWD.Quit Set appWD = Nothing
When I record a macro to change the orientation, Word changes several
PageSetup parameters instead of just .Orientation. Perhaps you could
try including all of these and then try eliminating them one by one
until you have the smallest set necessary.
James A. Fortune
Unless you are programming the change of orientation within Word, other
programme won't know what wdOrientLandsca pe means.
Replace it with 1 and you should be fine.
Herbert
"Ronny Sigo" <roon ad skynet.be> ¦b¶l¥ó
news:41******** *************** @news.skynet.be ¤¤¼¶¼g... Hello all, I am trying to programmaticall y change the orientation of a MS Word
Document to landscape. I must be doing something wrong cause it does not work ...
can anybody help me with this? Code is below .... Much obliged ... Ronny Sigo
Dim appWD As Object Dim myDoc As Object Dim sSavestring As String Set appWD = CreateObject("W ord.Application ") appWD.Visible = True With appWD Set myDoc = .Documents.Add .Documents(1).A ctivate With .ActiveDocument .PageSetup .Orientation = wdOrientLandsca pe End With .WindowState = wdWindowStateMa ximize With .Selection cm = 1 .PageSetup.Left Margin = CentimetersNaar Punten(cm) .PageSetup.Righ tMargin = CentimetersNaar Punten(cm) .PageSetup.TopM argin = CentimetersNaar Punten(cm) .ParagraphForma t.LeftIndent = 0 .ParagraphForma t.LineSpacing = 13 .Font.Name = "Arial" .Font.Color = vbRed .Font.Italic = True .InlineShapes.A ddPicture FileName:= _ "\\MyPath\Myfil e.bmp", LinkToFile:=Fal se, _ SaveWithDocumen t:=True .insertafter Text:=" Lijst alle contacten de4000 " .Font.Size = 24 .Font.Bold = True .Collapse Direction:=wdCo llapseEnd .insertafter Text:=vbCrLf .insertafter Text:=vbTab & vbTab & vbTab .insertafter Text:="Bestand aangemaakt op: " .Font.Size = 12 .Font.Bold = False .insertafter Text:=Date & vbCr & vbCr & vbCr .Collapse Direction:=wdCo llapseEnd End With sSavestring = "\\MyPath\MyFil e" & Year(Date) & "-" &
Month(Date) & "-" & _ Day(Date) myDoc.SaveAs FileName:=sSave string End With 'appWD.Quit Set appWD = Nothing If theError = 429 Then appWD.Quit Set appWD = Nothing
This works great:)
Thank you Herbert
"Herbert Chan" <he*****@chan.c om> schreef in bericht
news:2o******** ****@uni-berlin.de... Unless you are programming the change of orientation within Word, other programme won't know what wdOrientLandsca pe means.
Replace it with 1 and you should be fine.
Herbert
"Ronny Sigo" <roon ad skynet.be> ¦b¶l¥ó news:41******** *************** @news.skynet.be ¤¤¼¶¼g... Hello all, I am trying to programmaticall y change the orientation of a MS Word Document to landscape. I must be doing something wrong cause it does not work ... can anybody help me with this? Code is below .... Much obliged ... Ronny Sigo
Dim appWD As Object Dim myDoc As Object Dim sSavestring As String Set appWD = CreateObject("W ord.Application ") appWD.Visible = True With appWD Set myDoc = .Documents.Add .Documents(1).A ctivate With .ActiveDocument .PageSetup .Orientation = wdOrientLandsca pe End With .WindowState = wdWindowStateMa ximize With .Selection cm = 1 .PageSetup.Left Margin = CentimetersNaar Punten(cm) .PageSetup.Righ tMargin = CentimetersNaar Punten(cm) .PageSetup.TopM argin = CentimetersNaar Punten(cm) .ParagraphForma t.LeftIndent = 0 .ParagraphForma t.LineSpacing = 13 .Font.Name = "Arial" .Font.Color = vbRed .Font.Italic = True .InlineShapes.A ddPicture FileName:= _ "\\MyPath\Myfil e.bmp", LinkToFile:=Fal se, _ SaveWithDocumen t:=True .insertafter Text:=" Lijst alle contacten de4000 " .Font.Size = 24 .Font.Bold = True .Collapse Direction:=wdCo llapseEnd .insertafter Text:=vbCrLf .insertafter Text:=vbTab & vbTab & vbTab .insertafter Text:="Bestand aangemaakt op: " .Font.Size = 12 .Font.Bold = False .insertafter Text:=Date & vbCr & vbCr & vbCr .Collapse Direction:=wdCo llapseEnd End With sSavestring = "\\MyPath\MyFil e" & Year(Date) & "-" & Month(Date) & "-" & _ Day(Date) myDoc.SaveAs FileName:=sSave string End With 'appWD.Quit Set appWD = Nothing If theError = 429 Then appWD.Quit Set appWD = Nothing
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: temp |
last post by:
Hi,
I'm not good in regexp.
TEXT:
<a href="index.php">asasa</a>
<a taget href='index.php'>asasas</a>
I want to change only "index.php" in all occurance in a link tag.
|
by: mharris |
last post by:
I need help with merging two Word documents into one through C#
code. The problem isn't so much getting the documents put into one as
it is maintaining the appropriate formatting, or rather reformating,
after the merge. This is a full description of my needs.
I have a C# class library that creates two Crystal Reports, and then
exports them to the harddrive as Word documents. One's orientation is
landscape, the other is portrait. I then...
|
by: Adam Faulkner via DotNetMonster.com |
last post by:
I had a problem before extracting pages from an existing word document and
then inserting the content into a new word document.
The following code below works with Microsoft Word 2000
Function ParseWordDoc(ByVal Filename As String) As String
Dim sNewFileName As String
Dim WordApp As Word.Application = New Word.Application
Dim BaseDoc As Word.Document
Dim DestDoc As Word.Document
|
by: SEGACO |
last post by:
I need to create a report in a datagrid that displays some data in vertical
orientation, for example
STATE CITY
Florida Miami
Florida Miami
Florida Miami
that only Florida appear in all the rows, but in vertical orientation in all
the column cells that it use.
|
by: Mike |
last post by:
I'm looking for a wireless mouse that which allows me to change the X-Y
orientation, so that left is right, right is left, up is down, and down is
up. Can anyone point me in the right direction?
| |
by: cgd |
last post by:
hi,
i want to save the MS Word data (not the Word file) to a database,
so i copy the Word data to clipboard first,and then get the data to a
DataObject object, and then try the code below,
Formatter.Serialize(StreamTemp, dbObject); //but it can't be Serialized,
StreamTemp.Close();
Return StreamTemp.GetBuffer() ;
|
by: iszact |
last post by:
Greetings all..
I hope you guys can help me with this.
I've been doing a database for my microbiology labs, but having difficulties to change a species name into italic font.
Here's what I want to do:
Mycobacterium tuberculosis NOT isolated
Can anybody please help me with this so that ONLY "Mycobacterium tuberculosis" appear in italic font in database form, and report.
|
by: Drupan c |
last post by:
hello everybody,
i m new to vc# , i want an application where i can select multiple word files using File Dialog and change the page setup property of all the word files at once rather then changing it for each and every file manually..
is this possible using Microsoft.Office.Interop.Word namespace ??
plz guide me..
|
by: AndyDelbaere |
last post by:
Hello,
I have a word document with multiple pages.
I want to select a random page and be able to change the orientation (from portrait to landscape and vice versa)
This should only change the one page and not the whole document.
I think this should be with sections at the beginning and at the end of the selected page.
Office 2007 is used and the project itself is a shared addin for Word.
I have tried to solve this myself but it keeps...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |